Sponsored Content
Top Forums Shell Programming and Scripting Shell script to make and mount a Partition Post 302289450 by HernandJ2 on Thursday 19th of February 2009 03:36:34 PM
Old 02-19-2009
Shell script to make and mount a Partition

Hi,

I need to mount a new partition in a series of Pc that have a single hard drive of 20 GB; the used and partioned space amounts to 10 GB, between root, boot and swap; the script is to make the mounting process automatic


These are the contents of my script:
**********************************************
cd /
#gave the list of commands from the file "origin"
sbin/fdisk /dev/hda < origin

#read the partition table, format the new and give it a name "/data"

#partprobe doesn't work
#sfdisk /dev/hda -R doesn't work either

mkfs.ext3 /dev/hda4
e2label /dev/hda4 /data

#make a "/data" directory, and place it in fstab
mkdir /data
LINEA='/data /data ext3 defaults 1 1'
grep "$LINEA" /etc/fstab >/dev/null || echo $LINEA >> /etc/fstab
mount -a
**********************************************

And these are the contents of origin:
**************************************
n
e
1294
2434
w
**************************************


But here is where i'm having trouble, i can't seem to make the system re-read the partition table (doesn't have partprobe, and sfdisk /dev/hda -R doesn't work at all)

There is a way to make this script run at boot time, before it read the partition table, forcing it to make the changes? This script should run just once in every equip. I'm utterly lost here, i would appreciate any help in the solution.

I am new tho shell scripting and linux in general, perhaps this is not the right way to do what i want.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to mount fat16 partition

Hello, I am trying to mount a FAT16 and FAT32 partition on an already installed Redhat system. I have tried to edit the fstab and mtab, and to put in the data I got from fdisk, but it just says cannot find it. The information given by fdisk on /dev/hda is: Device Boot Start ... (4 Replies)
Discussion started by: ghoti
4 Replies

2. Solaris

can't mount a partition

Hello, I have a problem on my sun station, that run solaris7. To free temporarly a little space on /, I moved a few empty folders (mnt, net, awk, tftpboot) to the /home partition. Unfortunately the system froze just after this...maybe I should not have move this files, I don't know, I am a... (3 Replies)
Discussion started by: nabulus
3 Replies

3. Solaris

how to mount other partition?

dear all, that is my problem : c0d0p1 is nt, c0d0p2 is solaris and other on extended partition is pcfs, so how can i mount it somewhere? because i dont know which one connect from raw to block dev. /dev/rdsk/c0d0p? any help would be great... :) (6 Replies)
Discussion started by: stdout
6 Replies

4. UNIX for Dummies Questions & Answers

I've created a partition with GNU Parted, how do I mount the partition?

I've created a partition with GNU Parted, how do I mount the partition? The manual information at http://www.gnu.org/software/parted/manual/parted.html is good, but I am sure about how I mount the partition afterwards. Thanks, --Todd (1 Reply)
Discussion started by: jtp51
1 Replies

5. Solaris

can not mount the selected partition

Dear Brothers First i installed suse linux with the following partition. my hd0 size is 75gb hdc1 swap 1 gb hdc2 native linux 39gb For the rest of the 35 gb i did not create any partition. so i planned to install solaris 10x86 on that free space. When i installed the solaris i... (1 Reply)
Discussion started by: sayed_021
1 Replies

6. Shell Programming and Scripting

shell script Partition Creation

Hello all How is it going I want Shell Patch The work of the following division of the disk Can this 200 MB EXT3 /boot 20 Gb EXT3 / 10 GB Swap End Of Space ( Linux LVM ) Found a similar script can be customized by you to be the work required #!/bin/bash VSIZE=200 fdisk /dev/hda... (1 Reply)
Discussion started by: x-zer0
1 Replies

7. UNIX for Dummies Questions & Answers

mount extended partition

Hello, Im new here, and may be my question is stupid, but... Today I run PGP Desktop decript on my 2nd partition ( D:\ ) and when decript finish, I restart my PC.Now when I try to open D:\ its give me: D:\ is not accessable and I lose my files :( So I load Linux live CD ( knoppix ) and try to... (1 Reply)
Discussion started by: mrowcp
1 Replies

8. Shell Programming and Scripting

Cygwin bash script to unmount and mount an XP partition

As stated, I am looking into keeping my backup drive unmounted in normal windows use. Partly this is to address threats like cryptolocker. Since one of my backup drives is an internal drive, it will not likely afford any protection from such a threat. I am thinking of adding code to my rsync script... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

9. UNIX for Dummies Questions & Answers

Mount UEFI partition

I want to gain read/write access to a Windows 8 partition from a linux live cd. Prior to Windows 8, I used ntfs-3g to mount the partition from the command line. The "Fdisk -l" command does not seem to be able to read efi partitions. There must be some new strategy for linux users. This is... (6 Replies)
Discussion started by: jamarsh
6 Replies

10. AIX

Can't mount a partition

Hello, today i get some aix errors (can't lock files and strange things) then i umount FS to do a fsck but i get these errors root@omega / > fsck -p /dev/fslv06 The current volume is: /dev/fslv06 Unable to read primary superblock. Unable to read either superblock. I readed on this page... (9 Replies)
Discussion started by: thorin666
9 Replies
CFDISK(8)                                                      System Administration                                                     CFDISK(8)

NAME
cfdisk - display or manipulate a disk partition table SYNOPSIS
cfdisk [options] [device] DESCRIPTION
cfdisk is a curses-based program for partitioning any block device. The default device is /dev/sda. Note that cfdisk provides basic partitioning functionality with a user-friendly interface. If you need advanced features, use fdisk(8) instead. Since version 2.25 cfdisk supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any functionality for CHS (Cylinder- Head-Sector) addressing. CHS has never been important for Linux, and this addressing concept does not make any sense for new devices. Since version 2.25 cfdisk also does not provide a 'print' command any more. This functionality is provided by the utilities partx(8) and lsblk(8) in a very comfortable and rich way. If you want to remove an old partition table from a device, use wipefs(8). OPTIONS
-h, --help Display help text and exit. -L, --color[=when] Colorize the output. The optional argument when can be auto, never or always. If the when argument is omitted, it defaults to auto. The colors can be disabled, for the current built-in default see --help output. See also the COLORS section. -V, --version Display version information and exit. -z, --zero Start with an in-memory zeroed partition table. This option does not zero the partition table on the disk; rather, it simply starts the program without reading the existing partition table. This option allows you to create a new partition table from scratch or from an sfdisk-compatible script. COMMANDS
The commands for cfdisk can be entered by pressing the corresponding key (pressing Enter after the command is not necessary). Here is a list of the available commands: b Toggle the bootable flag of the current partition. This allows you to select which primary partition is bootable on the drive. This command may not be available for all partition label types. d Delete the current partition. This will convert the current partition into free space and merge it with any free space immediately surrounding the current partition. A partition already marked as free space or marked as unusable cannot be deleted. h Show the help screen. n Create a new partition from free space. cfdisk then prompts you for the size of the partition you want to create. The default size is equal to the entire available free space at the current position. The size may be followed by a multiplicative suffix: KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g. "K" has the same meaning as "KiB"). q Quit the program. This will exit the program without writing any data to the disk. s Sort the partitions in ascending start-sector order. When deleting and adding partitions, it is likely that the numbering of the partitions will no longer match their order on the disk. This command restores that match. t Change the partition type. By default, new partitions are created as Linux partitions. u Dump the current in-memory partition table to an sfdisk-compatible script file. The script files are compatible between cfdisk, fdisk, sfdisk and other libfdisk applications. For more details see sfdisk(8). It is also possible to load an sfdisk-script into cfdisk if there is no partition table on the device or when you start cfdisk with the --zero command-line option. W Write the partition table to disk (you must enter an uppercase W). Since this might destroy data on the disk, you must either con- firm or deny the write by entering `yes' or `no'. If you enter `yes', cfdisk will write the partition table to disk and then tell the kernel to re-read the partition table from the disk. The re-reading of the partition table does not always work. In such a case you need to inform the kernel about any new partitions by using partprobe(8) or partx(8), or by rebooting the system. x Toggle extra information about a partition. Up Arrow, Down Arrow Move the cursor to the previous or next partition. If there are more partitions than can be displayed on a screen, you can display the next (previous) set of partitions by moving down (up) at the last (first) partition displayed on the screen. Left Arrow, Right Arrow Select the preceding or the next menu item. Hitting Enter will execute the currently selected item. All commands can be entered with either uppercase or lowercase letters (except for Write). When in a submenu or at a prompt, you can hit the Esc key to return to the main menu. COLORS
Implicit coloring can be disabled by creating the empty file /etc/terminal-colors.d/cfdisk.disable. See terminal-colors.d(5) for more details about colorization configuration. cfdisk does not support color customization with a color-scheme file. ENVIRONMENT
CFDISK_DEBUG=all enables cfdisk debug output. LIBFDISK_DEBUG=all enables libfdisk debug output. LIBBLKID_DEBUG=all enables libblkid debug output. LIBSMARTCOLS_DEBUG=all enables libsmartcols debug output. LIBSMARTCOLS_DEBUG_PADDING=on use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG. SEE ALSO
fdisk(8), parted(8), partprobe(8), partx(8), sfdisk(8) AUTHOR
Karel Zak <kzak@redhat.com> The current cfdisk implementation is based on the original cfdisk from Kevin E. Martin (martin@cs.unc.edu). AVAILABILITY
The cfdisk command is part of the util-linux package and is available from https://www.kernel.org/pub/linux/utils/util-linux/. util-linux March 2014 CFDISK(8)
All times are GMT -4. The time now is 10:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy