WebSphere Issues


Linux disk partitions using file and loop device

Filed under: Linux — Tags: — Ishtiaque @ 1:03 pm

1. Create a 1 GB file:

  • dd if=/dev/zero of=imgfile bs=1M count=1024

2. Mount the file onto a loop device

  • losetup -f  imgfile
  • losetupa (OR -l)

3. Create Partitions:

  • fdisk /dev/loop0 (OR /dev/sda)
  • Press ‘n’ for new
  • Press ‘p’ for primary and ‘e’ for extended partition
  • Enter partition size for example as +256M
  • Press ‘p’ to print the partition table
  • Press ‘w’ to save and exit

4. Reload and list partitions:

  • partprobe /dev/loop0
  • cat /proc/partitions
  • ls -l /dev/loop0*
  • fdisk -l /dev/loop0
  • partprobe -s /dev/loop0

5. Format partitions:

  • mkfs -t ext4 /dev/loop0

6. Mount partition:

  • mkdir mntp1
  • mount -o loop /dev/loop0p1 mntp1
  • df -hT
  • umount mntp1 (Unmount a partition)

Create a free website or blog at WordPress.com.

%d bloggers like this: