Partition a New Disk

Linux lab Intermediate 5 tasks 20 points

A new 128 MiB disk, big.img, needs to be split into two partitions before it can be used. Attach it, give it an MBR (msdos) partition table with two primary partitions, then format and mount the first one at /mnt/part1. Password: student.

How it works: the terminal below is a real Linux machine running in your browser. Click it and type. Tasks tick themselves off as you complete them; questions are answered in the box under each task. Press Reset any time for a fresh machine. Your password on this machine (for sudo) is student.

student@vulntech:~ Starting…
Getting your Linux machine ready…
The first start downloads about 20 MB. After that your browser keeps it, and labs start in a moment.

Hints

Attach first, then partition the whole disk (/dev/loop0), then work on the partition (/dev/loop0p1).

parted -s runs non-interactively; sizes like 1MiB and 64MiB set where each partition starts and ends.

Solution explanation

sudo losetup -fP --show big.img attaches the disk as /dev/loop0 (-P so its partitions appear as /dev/loop0p1, /dev/loop0p2). parted mklabel msdos writes an MBR table and each mkpart adds a partition. A partition is a block device in its own right, so mkfs.ext4 /dev/loop0p1 formats the first one and mount attaches it at /mnt/part1.

Show solution
sudo losetup -fP --show big.img
sudo parted -s /dev/loop0 mklabel msdos
sudo parted -s /dev/loop0 mkpart primary ext4 1MiB 64MiB
sudo parted -s /dev/loop0 mkpart primary ext4 64MiB 100%
lsblk /dev/loop0
sudo mkfs.ext4 /dev/loop0p1
sudo mkdir -p /mnt/part1
sudo mount /dev/loop0p1 /mnt/part1
HOME LEARN COMMUNITY DASHBOARD