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
BOOTCD2DISK.CONF(5)						   bootcd utils 					       BOOTCD2DISK.CONF(5)

NAME
bootcd2disk.conf - configuration file for bootcd2disk DESCRIPTION
The file bootcd2disk.conf contains configuration option for the bootcd2disk(1) program of the same named package. The file must be located in the configuration directory which is usually /etc/bootcd. Blank lines are ignored and lines with leading # are comments. Values have to be set with name=value You can use a wildcard named DISK<number> to specify partitions instead of e.g. /dev/hda<number>. DISK was replaced by $DISK, which can be set by the same named parameter. FORMAT
ERRLOG=<path> Write all errors to this file. Required. DISK=<device|auto> Specify the disk you want to use for the installation, e.g. /dev/hda for the first IDE drive in the system. If you use "auto", bootcd2disk automatically try to use the first hard disk in the system. Required. SFDISK=<partitions in sfdisk syntax|auto> Configuration options for sfdisk, which creates the partitions for us. If you use "auto", we create default partitions "/", "/boot" and a swap partition. Required. VFAT=<partitions separated by spaces> Configure vfat partitions there, if you need some. Optional. EXT2FS=<partitions separated by spaces|auto> Specify the partitions with ext2 or ext3 (see next parameter) here. This partitions would be created and formated. If you use "auto", the "/" and the "/boot" partition would be created. Required. EXT3FS=<yes|no> Enter "yes" If you want ext3 partitions. If you use "auto", the systems use ext3 partition, if the kernel supports it. Required. SWAP=<partitions separated by spaces|auto> The partitions configured there are created as swap. If you use "auto", one swap partition is been created. Required. MOUNT=<mount <partition> <mountpoint>; ... |auto> Insert here the mount command line to mount your partitions or use "auto". Required. UMOUNT=<umount <mountpoint>; ... |auto> Insert here the mount command line to umount your partitions or use "auto". Required. FSTAB=<entries for the systems fstab |auto> Configure here all partitions you need to mount after target systems startup in the fstab syntax or use "auto". Required. LILO=<entries for the systems lilo.conf |auto> This variable includes the complete configuration file for the lilo bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want LILO. Make sure GRUB and GRUB2 are defined as empty if you want to use LILO. GRUB=<entries for the systems grub/menu.lst |auto> This variable includes the complete configuration file for the grub bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want GRUB. GRUB2=<entries for the systems grub/grub.cfg |auto> This variable includes the complete configuration file for the grub2 bootloader on the target system. Use "auto" for automatically generated file. Only required, if you want GRUB 2. GRUBBOOTDIR=<number of partition which contains grub-dir | 0> This variable defines the partition where the grub bootloader information is stored. You want to use this if you have defined your own partition layout and the grub information is not on the first partition. Remember that grub starts counting partitions at 0. So if you decided that /boot is on partition /dev/sda2 you need to set the parameter to 1. GRUBBOOTDISK=<grub disk> This should be "hd0". Only if your BIOS sees another disk as the first disk you may have to change it. GRUBDEVICEMAP=<auto|no|<value>> GRUBDEVICEMAP="auto" means, bootcd2disk deletes the original device.map, so that it will be auto-created by grub again. This should work also when installing on different hardware with different disks. GRUBDEVICEMAP="no" means bootcd2disk does not change device.map. This should work if a bootcd is installed on the original hardware Everything else will be used as new value for device.map. ELILO=<entries for the systems elilo.conf |auto> Same as LILO but for the elilo bootloader on ia64 systems. Use "auto" for automatically generated file. Only required, if you want ELILO. SSHOSTKEY=<yes|no> If you are using ssh it is helpful to have a unique ssh hostkey for each system installed with bootcd2disk. This will be generated if this option is set to "yes". Required. UDEV_FIXNET=<yes|no> If you are using the udev filesystem and want to install the image on other machines, you need to set this to "yes" because the net- work interfaces are hardwired in /etc/udev/rules.d/z25_persistent-net.rules (etch) or in /etc/udev/rules.d/70-persistent-net.rules (lenny) and we must remove them. Required. IMAGEURL=<url> If bootcd2disk is slow on your system (because of a slow CD/DVD drive or the HP ILO virtual CD interface), you can use a image server to get the bootcdimage from. bootcd2disk use the swap partition of your upcoming system as temporary space and copy the image from the configured image server to this partition and use it as image. May be overwritten from command line "-url". Need the following parameter "IMAGEURL". Required. The <url> is used with wget, all url syntax from wget are possible. Please use a ip because of failed DNS and you need also the con- figured ip interface. May be overwritten from command line (-url). Required. example: IMAGEPURL="https://192.168.1.1:81/cdimage.iso" function before_copy() { return } If you want some action before copying the system to the target disk, like remount or other thinks, you can write this action to the body of this function. Optional. function after_copy() { return } If you want some action after copying the system to the target disk, like remount or other thinks, you can write this action to the body of this function. Optional. SEE ALSO
bootcd2disk(1), bootcd(1), bootcdflopcp(1), bootcdwrite(1) AUTHOR
This manual page was written by Carsten Dinkelmann <carsten.dinkelmann@foobar-cpa.de>, for the Debian GNU/Linux system (but may be used by others). bootcd2disk.conf 2007-04-04 BOOTCD2DISK.CONF(5)
All times are GMT -4. The time now is 05:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy