 In this video, I'm going to show you some of the basics of FDisk. What is FDisk? FDisk is a partition manager. It allows you to create partitions. So this is typically used when you're installing Linux, especially using command line installations of Linux. So when you're installing really minimal Linux distributions like Arch Linux, Gen2, many server distributions, typically they involve you installing Linux through the command line and you have to actually use command line tools to partition your disks. Now there's several command line partitioning tools out there. FDisk is probably the standard tool. It's typically the one that you see recommended in most Linux distributions wikis. So that's the one I'm going to talk about today. So let me switch over to my desktop because I've got a virtual machine that I quickly spun up here. So this is Arch Linux. I'm just booting directly off the live ISO for Arch Linux. So this is the very first part of the installation which is typically the most important part of the installation of any Linux distribution is the very first thing you typically want to do is partition your drives. So how you typically want to do this is you want to run as root or with sudo privileges FDisk-L, give it the L flag and this is for list. This lists all the devices on your system. So basically all of your hard drives is typically what it's going to list out. So I have slash div slash VDA for virtual disk. And I also have slash dev slash VDB because I created two virtual hard drives in this virtual machine. I also have the loopback device. We'll just ignore that. But typically however many hard drives, solid state drives, NVMe drives, they're all going to be mounted at slash div. They're going to be given a specific name. So typically SD drives or SDA, SDB, SDC, et cetera, hard drives, HDA, HDB, HDC, et cetera. And if you have NVMe drives, they're going to read something like slash dev slash NVMe, zero in one or slash dev slash NVMe, zero in two, et cetera, et cetera. Now I can't stress enough that it's always important to go ahead and run the FDisk-L command first before getting started because you want to make sure you know the exact names of the devices in your system because you don't want to accidentally format a drive, the wrong drive. You know, I don't want to accidentally format slash dev slash VDB when I meant to format slash dev slash VDA, you know, right? So make sure that you get a listing of all your devices if you have multiple drives in your system. And then once you know the drive you want to format, go ahead and run as root or with sudo privileges, FDisk space, and then the name of the device. So I'm going to do slash dev slash VDA. And then we get into this new interactive FDisk prompt where we can start typing commands that FDisk understands. If you don't know the commands, you can see that you can type M for help. Why is it M for help? I'm assuming M stands for help menu. So think of that, you know, if it's kind of weird to think of M for help, but think of it as a help menu. So if I type M and hit enter, we get all the commands that are available for us here in this part of FDisk. So before partitioning anything, you need to create a empty partition table. Typically on Linux, we're either going to create a DOS partition table, which is for master boot record legacy BIOS, or you're going to create a GPT partition table, and that's for use with UEFI. So in this VM, I'm going to do a legacy DOS partition table. So I'm going to type O because you can see the last four key bindings are the create new label key bindings, and O creates a new empty DOS partition table. And now that we've done that, the next thing I want to do is create a new partition. And under the generic key bindings, you see N adds a new partition. So N for new partition is going to ask, what is this new partition going to be as far as the type? Is it a primary partition or is an extended partition? So I'm going to create a swap. I'm going to do like a one gig swap, and it needs to be a primary partition. Now for a DOS partition table, we have up to four partitions available. If you're doing UEFI, you have up to 128 partitions available. So the very first partition I created, the swap partition, will be partition number one. And the very first sector of that partition just needs to be the very first sector. Just hit enter and go with the default number for that. And then the last sector, how big do you want this? You can give it an exact number in bytes. But what I typically do is I just do plus one capital G for one gigabyte. So start at the beginning and then go plus one gigabyte in size. And that created a new partition. And you can see by default, it creates it as a Linux file system. That's the type. We're going to change that to swap here in a minute. And it was one gigabyte in size. Now that I created a one gig swap, I need to create a real file system, you know, the big file system for like my extend for file system. So I'm going to go ahead and type in for new partition. This once again will be primary, so P for primary, partition number. This time it'll be partition number two. The first sector, again, is the first sector available. Just hit enter. And then the last sector, you could give it an exact size. But in my case, I wanted to take up the entire rest of the disk. So all I have to do here is just hit enter. And you can see it created partition to type Linux, which is correct this time. Size 19 gigabytes, because this 20 gig device, this virtual disk has a 20 gig disk. And we gave one gig to the swap. And then the rest of it was the 19 gigs left for what's going to be my extend for file system. Now remember, partition one was swapped, but it created it as a partition type Linux, which isn't correct. So we need to change the type. If I type M, you can see under generic T for change partition type. So let's do that. Hit enter. Which partition are we changing? We're changing partition one. And then what is the type? Type capital L to list all the partition type we need should be called Linux swap. And actually you can see it under aliases. You see Linux is 83 and swap is 82. So just type 82 for swap. And now, if I do M for help, under the generic keybindings, you can see P prints the partition table. So I'm going to type P, because I want to see if that actually changed. Yes, now slash dev slash VDA one, one gigabyte. And you can see the type is Linux swap slash dev slash VDA two is 19 gigs and it's type Linux. Now you'll notice when I print it out the list here, you can see there is a column for boot. Neither one of these partitions is bootable. And of course, the big partition, the VDA two needs to be bootable. So we can add a boot flag to that. If you look at the key bindings, there should be a key binding to actually make a partition bootable. Let me type in to get a fresh help screen here. And you can see the very first key binding, A toggles a bootable flag. So if I type A, it's going to ask which partition do we want to make bootable. I'm going to do two because that's VDA two. So now once again, I'm going to type P and you can see there is a asterisk under the boot column for VDA two. So all of this looks good. Now we're ready to actually write the changes. So W would write and then it automatically quits after that. Now, if you were didn't want to save, so you had partitioned everything and you realized you made a mistake and you didn't want to write, you could always queue to quit without writing the changes. But in this case, we wrote our changes and it's ready to go. Now, remember, I had a second drive here. If I do fdisk space dash L again, remember we also had a slash dev slash VDB drive. And I could certainly do something with that drive. Maybe what I like to do on my secondary drives, I like to have them as dedicated partitions for their own directory. So I like to have my music folder, for example, on its own partition on its own separate drive. That way, I never have to worry about when I reinstall moving hundreds of gigabytes of music that I have stored on one disk in this computer. That's kind of nice. You may want to have your videos directory stored on its own partition on its own separate drive or your home directory. Some people just like having their entire home directory on a separate partition. So we certainly could do that. I could go back into fdisk and we could this time do slash dev slash VDB for the second drive. And this drive is 20 gigabytes in size. And this time I'm gonna do in for new and then primary partition and then partition number one. And then the first sector, we'll just start at the first sector. And then the last sector, I'm gonna make the entire 20 gig hard drive, the secondary hard drive, just one partition. And it created it as type Linux, which is correct. I'll do another extend for file system for this. It doesn't need to be bootable because we won't be booting off of this disk. This secondary disk will be something that gets auto mounted because we'll add this to our FS tab or file system table later. So this is all good. I'm just gonna do W to write that. And now when I do fdisk dash L, you see we get some different information and we actually get the actual file system tables that we've created here, VDA1, VDA2, VDB1. And that's really everything you need to know about fdisk. I mean, from that point forward, the rest of the installation would involve other command line tools. We've already done the partitioning. I can actually show you some of the other tools that you'd commonly wanna use after fdisk. So now that we've done this, typically what you wanna do, let me clear the screen here. You wanna go ahead and make your file systems. So what typically you wanna do is, as root or with sudo privileges, you wanna go ahead and MK swap. So make swap and you need to give it a device. So in my case, I made my swap at slash dev slash VDA1. And you can see it's setting up swap space. Then you need to turn the swap on. So swap on slash dev slash VDA1. So now we've made the swap and then we've turned the swap on. Now let's make our extend for file systems. So you wanna do this as root or with sudo privileges, MKFS for make file system dot ext4. And then the name of the device I'm gonna do slash dev slash VDA2. And we've made that file system. And remember, we have another drive. We had VDB with just one partition. So VDB1, I'm also gonna make that an extend for file system for mounting our home directory on its own partition or my music directory or video directory, whatever it is I wanna add to that secondary drive. And then let me clear the screen. Now, if I wanna test out if that secondary drive, you know, the VDB drive actually would work when we mount it. Let's go ahead and try it here at the command line. So I'm gonna as root mount slash dev slash VDB1 because it needs to be a specific partition. And then where do we wanna mount that to? We wanna mount that to slash MNT slash, let's assume that it's gonna be my music directory. It says slash MNT slash music mount point does not exist. So let's go ahead and make dear slash MNT slash music and then rerun the mount command. So again, mount slash dev slash VDB1 at slash MNT slash music. And now that drive has been mounted to that particular directory. Of course, there's no music in that directory. This is a fresh VM. There's actually nothing to do here. Typically what you wanna do on physical hardware on your real hardware, you wanna actually auto mount using your FS tab, your file system, table file. Typically what you wanna do as root, you wanna open that with VM or whatever editor you use nano slash Etsy slash FS tab. And in this live environment on Arch Linux, there actually isn't a working FS tab because that actually gets created later during the installation process. And I'm not actually gonna run through an entire Arch installation, but I will show you how I do it on my physical machine. Let me actually switch to a different workspace here. So let me open up a terminal here. And this is actually my physical machine. This isn't a virtual machine anymore. So if I do it LSBLK for list block devices, you can actually see I have several drives, ignore all the loopback devices. These are snaps that are installed, but I have actual physical drives installed, several of them. I have four SSD drives. I have SDA, SDB, SDC, SDD. So four different solid state drives. I have an NVME drive as well. And if I did a sudo, because we need sudo privileges here, BLKID for block ID, and then give it my password here, you can see I can get the UUID. This is a number that is used to identify our drives or our block devices here. And what I'm doing is SDB is actually my music directory. So I have a drive, I have a 256 gig SSD drive that is mounted to my music directory. So I get the UUID using the block ID command. And then what I could do is then I could go into my FS tab. And you can see, I just add that UUID, the mount point, the mount point is my music directory. And then it's an extend for file system, defaults, and then zero and two. And that's all I did. Just add that simple line there. Not very complicated at all. Then reboot. And then that secondary drive, in my case, SDB should auto-mount, and it definitely auto-mounts because if I open my graphical file manager here and go to my music directory, you can see it's actually here. I actually have music here and it actually works. If it didn't work, we actually couldn't read anything in this directory. And of course it will actually play music as well. If I wanted to play something for you guys. Let me kill that. That's a little bit of me playing there. So I actually got a little bit off track with FDisk. You got a little bit of how to use FDisk plus some other tools. Now there's plenty of other command line partition managers other than FDisk. One I like to use sometimes is a program called CFDisk, which is very easy to use. It's, you've got just a few controls at the bottom. You can see bootable, delete, resize, quit, type, help. If I move my head out of the way, there's a couple more commands, right. It's very self-explanatory. I really don't need to show you guys how to use CFDisk. CFDisk is typically used for DOS partition tables. So master boot record. You could also use CGDisk for those of you that prefer UEFI. It's exactly like CFDisk, it's just for UEFI partitions. And since I created this as a DOS partition table, I don't actually think it would let me run this. If I tried to run it on slash dev slash VDA, for example, it probably will complain. Yeah, warning non-GPT. So it knows we already created this as a DOS partition table. So I'm actually just gonna cancel that. So there are other available tools. FDisk, again, it's kind of the standard. So when you go to the ArchWiki, the Gen2 wiki, pretty much anybody's wiki and they tell you, hey, you need to partition a drive, use FDisk. So it's the tool that I recommend you guys learn. Now before I go, I need to think a few special people. I need to think the producers of the show. And of course I'm talking about Absi Gabe James Mitchell, Paul Scott-Wiss, Akami Allen-Chuck, Commander-Angry, Kurt David Dillon-Gray-Gray, Heiko Mike-Uryan, Alexander Peace-Arch and Fedor, Bolly Dick-Rever, Rip-Rovot, Steven and Willie. These guys, they're my high-steered patrons over on Patreon without these guys. This quick video about the basics of the FDisk command line partition manager, it wouldn't have been possible. The show is also brought to you by each and every one of these ladies and gentlemen as well. All these names you're seeing on the screen, these are all my supporters over on Patreon because I don't have any corporate sponsors. It's just me and you guys, the community, if you like my work and wanna help support me please. Subscribe to DistroTube over on Patreon. Peace. And once you have the drive partition, you've done half the arch installation.