I have a script which partition the directory into two equal partition. I am partitioning /mnt
directory into two equal partitions /data01
and /data02
.
david@machine:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda 30G 1.2G 27G 5% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 26G 12K 26G 1% /dev
tmpfs 5.2G 372K 5.2G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 26G 0 26G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/vdb 276G 63M 262G 1% /mnt
Below is my script:
#!/bin/bash -x
#
#
# Comment the mnt from fstab
umount /mnt
sed -i '{
s#^/dev/vdb#\#/dev/vdb#
}' /etc/fstab
echo '# partition table of /dev/vdb
unit: sectors
/dev/vdb1 : start= 2048, size=2147481600, Id=83
/dev/vdb2 : start=2147483648, size=2147483647, Id=83
/dev/vdb3 : start= 0, size= 0, Id= 0
/dev/vdb4 : start= 0, size= 0, Id= 0
' | sfdisk /dev/vdb
# Create the links since it over 2TB disk
partprobe
# make file system
mkfs -t ext4 /dev/vdb1
mkfs -t ext4 /dev/vdb2
# mkdir dst dirs
mkdir /data01 /data02
D1=`blkid /dev/vdb1 | awk '{print $2}'`
D2=`blkid /dev/vdb2 | awk '{print $2}'`
echo "$D1 /data01 ext4 rw,noatime,nodiratime 0 2" >> /etc/fstab
echo "$D2 /data02 ext4 rw,noatime,nodiratime 0 2" >> /etc/fstab
mount /data01
mount /data02
When I ran the above script, it unmounted successfully /mnt
directory but it failed afterwards with this error message. Same script worked fine on other machine I had so looks like something is different in this box which I am not considering it in my script and because of that it is failing.
Below is the full debug messages:
+ umount /mnt
+ sed -i '{
s#^/dev/vdb#\#/dev/vdb#
}' /etc/fstab
+ echo '# partition table of /dev/vdb
unit: sectors
/dev/vdb1 : start= 2048, size=2147481600, Id=83
/dev/vdb2 : start=2147483648, size=2147483647, Id=83
/dev/vdb3 : start= 0, size= 0, Id= 0
/dev/vdb4 : start= 0, size= 0, Id= 0
+ sfdisk /dev/vdb
'
Checking that no-one is using this disk right now ...
OK
Disk /dev/vdb: 582542 cylinders, 16 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/vdb: unrecognized partition table type
Old situation:
No partitions found
Warning: given size (2147481600) exceeds max allowable size (587200512)
sfdisk: bad input
+ partprobe
+ mkfs -t ext4 /dev/vdb1
mke2fs 1.42.9 (4-Feb-2014)
Could not stat /dev/vdb1 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
+ mkfs -t ext4 /dev/vdb2
mke2fs 1.42.9 (4-Feb-2014)
Could not stat /dev/vdb2 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
+ mkdir /data01 /data02
++ blkid /dev/vdb1
++ awk '{print $2}'
+ D1=
++ blkid /dev/vdb2
++ awk '{print $2}'
+ D2=
+ echo ' /data01 ext4 rw,noatime,nodiratime 0 2'
+ echo ' /data02 ext4 rw,noatime,nodiratime 0 2'
+ mount /data01
mount: mount point ext4 does not exist
+ mount /data02
mount: mount point ext4 does not exist
What is wrong I did? How to fix this now? Looks like I messed up something.