Sponsored Content
Top Forums Shell Programming and Scripting Non-interactive fdisk partition in script Post 302731947 by jim mcnamara on Friday 16th of November 2012 05:10:18 AM
Old 11-16-2012
I personally would not run commands like fdisk that way, at the risk of screwing up a disk.
It is your disk, so:
in UNIX you create a script using a here document:
Code:
fdisk -u -p /dev/whatever <<EOF
n
p
1

w
EOF

EOF can be any word that the shell does not interpret as a command. You can even use a ! I picked EOF as a lot people use it... That last EOF has to be in column 1.
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

recovery partition table from fdisk?

I have two disks on a sun blade 100. I just installed a solaris8 on the first disk. The installation was successful. But the problem is now I lost all data / partition on my second hard disk. The possible reason could be: 1. I used default web start install. During the installation I didn't... (2 Replies)
Discussion started by: motor98
2 Replies

2. UNIX for Dummies Questions & Answers

Remove /dev/sdb partition using fdisk - BY ACCIDENT!

Hello everyone - Please forgive me if I violate the forum's etiquette as this is my very first post. I'm posting this on both the dummies and the advance section with the hope for any responses. I stumbled on this forum while frantically looking for an answer to a dumb, ignorant thing I did... (2 Replies)
Discussion started by: kevindoman
2 Replies

3. UNIX for Advanced & Expert Users

Remove /dev/sdb partition using fdisk - BY ACCIDENT!

Hello everyone - Please forgive me if I violate the forum's etiquette as this is my very first post. I'm posting this on both the dummies and the advance section with the hope for any responses. I stumbled on this forum while frantically looking for an answer to a dumb, ignorant thing I did... (5 Replies)
Discussion started by: kevindoman
5 Replies

4. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

5. Homework & Coursework Questions

How to write script that behaves both in interactive and non interactive mode

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (8 Replies)
Discussion started by: rits
8 Replies

6. Shell Programming and Scripting

Interactive script

Greetings gurus I have this simple scripts #!/bin/bash find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" > data_schema find /kl1/CTT/TQI_001/330_spike/sz00/latcon1/ -type d -name "*.dig" >> data_schema <data.schema awk '{print NR, "inVol=" $0, "setDt=4000",... (1 Reply)
Discussion started by: Marjan
1 Replies

7. Shell Programming and Scripting

Fdisk Call internals script?

I'm using fdisk -l > myFile to get the file size of the device in a file where I want the output but one line always go to the terminal and make my interface look ugly: Disk /dev/sda doesn't contain a valid partition table How do I stop this line from going to the command line with a... (2 Replies)
Discussion started by: darkstarxor
2 Replies

8. Filesystems, Disks and Memory

Partition management: lvm? fdisk? parted? (on RAID)

Hello, I have a RHEL system with two 500GB hard drives in RAID 1 (I think hardware, but not 100% certain - any way to tell?). It looks like it was just set up in default configuration with a small boot partition and one huge partition for the rest, which composes a LVM volume. I want... (1 Reply)
Discussion started by: builder88
1 Replies

9. Red Hat

Can I change the partition type with fdisk without disrupting data?

Hello, I have been going through our environment and I see we have a few servers with LVM's setup and the file system type is still set to "83" within fdisk. If I change this to "8e", will it hurt the data or cause any loss? I need to know for sure before I make the change. (1 Reply)
Discussion started by: s ladd
1 Replies

10. BSD

OpenBSD fdisk - Linux fdisk compatibility ?

Hello, MBR partition table made by linux fdisk looks certainly not correct when printed by openbsd fdisk: Partition table created on linux (centos 6.3): # fdisk -l /dev/sdc Disk /dev/sdc: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 *... (2 Replies)
Discussion started by: vilius
2 Replies
cmdk(7D)							      Devices								  cmdk(7D)

NAME
cmdk - common disk driver SYNOPSIS
cmdk@target, lun : [ partition | slice ] DESCRIPTION
The cmdk device driver is a common interface to various disk devices. The driver supports magnetic fixed disks and magnetic removable disks. The block-files access the disk using the system's normal buffering mechanism and are read and written without regard to physical disk records. There is also a "raw" interface that provides for direct transmission between the disk and the user's read or write buffer. A sin- gle read or write call usually results in one I/O operation; raw I/O is therefore considerably more efficient when many bytes are transmit- ted. The names of the block files are found in /dev/dsk; the names of the raw files are found in /dev/rdsk. I/O requests to the magnetic disk must have an offset and transfer length that is a multiple of 512 bytes or the driver returns an EINVAL error. Slice 0 is normally used for the root file system on a disk, slice 1 as a paging area (for example, swap), and slice 2 for backing up the entire fdisk partition for Solaris software. Other slices may be used for usr file systems or system reserved area. Fdisk partition 0 is to access the entire disk and is generally used by the fdisk(1M) program. FILES
/dev/dsk/cndn[s|p]n block device (IDE) /dev/rdsk/cndn[s|p]n raw device (IDE) where: cn controller n dn lun n (0-7) sn UNIX system slice n (0-15) pn fdisk partition(0) /kernel/drv/cmdk 32-bit kernel module. /kernel/drv/amd64/cmdk 64-bit kernel module. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |x86 | +-----------------------------+-----------------------------+ SEE ALSO
fdisk(1M), mount(1M), lseek(2), read(2), write(2), readdir(3C), scsi(4), vfstab(4), attributes(5), dkio(7I) SunOS 5.10 9 Oct 2004 cmdk(7D)
All times are GMT -4. The time now is 03:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy