Filesystem, mounting, partitions, oh my!


A lot of information got crammed into my brain tonight as I tried to understand the broad strokes of filesystems (for Linux), the different options available, then looking at some of the tools that are available for modifying filesystems. I tried parted and gdisk, but wound up feeling more comfortable with fdisk- for a starting point at least.

I first started by plugging in a usb memory drive that had been formatted on my Mac- my learning curve seemed destined to come to a screeching halt really fast as I couldn’t seem to even change that particular filesystem. It seemed stuck to the memory stick like old gum under a shoe. Yes, I pleaded and cajoled with fdisk to delete partitions, then create a new one, and after making the adjustments, selecting ‘w’ to write those changes into effect. However, after numerous times, the files wouldn’t synce.

So I started at the beginning:

sudo fdisk -l // list the storage devices, and I found the USB drive, which was /dev/sda1

sudo fdisk /dev/sda1 //opened up fdisk utility pointing at my USB drive

Here, now, I first deleted the partitions, and 'w' to save. That worked - so far so good.

Then, I created a new partition, using the Linux partition code- that was 83, I believe.

Once a partition is created, then you can create a filesystem

First, I made sure that the device was unmounted:
umount /dev/sda1

Then I created the filesystem with this:

sudo mkfs -t ext4 /dev/sda1 

Then comes mounting a filesystem. I did some googling and came up with this, which worked:

sudo mkdir /mnt/drive

sudo mount /dev/sda1 /mnt/drive

I found a resource that spelled things out very clearly- in retrospect the process doesn’t feel too complicated, but I suppose that’s the nature of learning, moving into the unknown and slowly gaining confidence. That doc can be found here.

[ connect usb drive ]
$ df -h  // check for drive, looking for storage capacity. If listed, the drive is mounted. Let's change that.

$ unmount /dev/sda1 // unmount the drive

$ sudo fdisk -l /dev/sda1 // point fdisk disk utility at drive

$ sudo mkfs -t ext4 /dev/sda1 // create file system if there isn't one already in place.

$ sudo mkdir /mnt/usbdrive // create a directory where you want to mount the drive

$ sudo mount /dev/sda1 /mnt/usbdrive // mount the drive




In summary, at the start I had a USB memory stick which had been formatted in a mac-specific formatting. I used fdisk to wipe that the partitions away as well as to format the drive with a ext4 file system. Then, I learned how to mount the drive to the linux system. Progress!


Leave a comment