linux - Unable to create filesystem on new partition - Amazon EC2 instance
2013-08
I created a new partition /dev/xvda1p1 on linux amazon ami. After that i am unable to create a filesystem.
What is the issue?
# fdisk -l
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3ace0183
Device Boot Start End Blocks Id System
/dev/xvda1p1 1 14 112423+ 83 Linux
# mkfs.ext4 /dev/xvda1p1
mke2fs 1.41.12 (17-May-2010)
Could not stat /dev/xvda1p1 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
Try tricks:
udevadm trigger
to make udev look for new devices and create /dev/xvda1p1blockdev --rereadpt /dev/xvda1
to explicitly tell it to re-read partition table on itmknod /dev/xvda1p1 b ${some_number} ${some_number2}
manually. ${some_number} is probably the same as in /dev/xvda1 and ${some_number2} is like /dev/xvda1's, but +1.- Finally, you can
losetup -o ${some_offset} /dev/loop0 /dev/xbda1
and use /dev/loop0. ${some_offset} is probably 8225280.
I'm running MSWindows virtualized with /dev/sda2 as it's primary drive. Consequently, there is a partition table on that partition, shown as:
# fdisk -l /dev/sda2
Disk /dev/sda2: 137.4 GB, 137436203520 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda2p1 * 1 16708 134206978+ 7 HPFS/NTFS
So my question is simply: What are the major/minor numbers to create /dev/sda2p1? What about sda2p2 and sda3p1?
Assuming this is a straight disk image (e.g., your virtualization solution is not adding some extra metadata to things), this document (also here) offers some suggestions for accessing your partitions on /dev/sda2 (summary: use the -o offset
option to losetup
to create a new block device referencing the appropriate offset into sda2).
You can also use the Network Block Device (NBD) to create a partitioned block device from /dev/sda2, see this LWN article which described the process in detail. And hey, I just learned something new.