Linux Tip | How to Add a Hard Drive to a Linux System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
greetings and salutations and thank you for clicking on this video today I'm going to show you how to add an extra hard drive to your Linux computer this is a subject that I have covered in the past but it's time to revisit this because I'm getting a lot of people who are asking me about this and I think I can do it better this time this time around I'm going to show you how to do it almost 100% graphically people who come to Linux from other operating systems they tend to get a little confused when it comes to storage devices because Linux handles storage devices in a much different way it doesn't assign a drive letter to it it doesn't automatically appear when you plug it in and that is because of the basic nature of how Linux works Linux was derived from Unix it's a work alike to the UNIX operating system not based on it but programmed to work just like UNIX and UNIX --that was designed to run big computers that would fill entire rooms that could literally have hundreds of storage devices hooked up anything from big reel-to-reel tape drives to hard drives the size of washing machines and we have that same functionality today in a modern Linux desktop or laptop computer now that can present a challenge because it is different but it also opens up a lot of options so we're going to take a long leisurely stroll through this process today and I'm going to try and tell you how to avoid the pitfalls that you might run into as you go through this process and also show you some of the different options that you have for how you actually utilize this new storage device you put in the machine so we're going to use a virtual machine today to do this but the procedure is exactly the same unreal hardware it does not change it's just easier to do it on a virtual machine because we can pretty much manipulate it any way we like right so we'll go to settings and we're going to look at storage and the first thing that we're going to do is add a hard drive and so simple to do in a virtual machine just add hard disk and we will create a new drive to do this and dynamically allocated is fine they don't care how big we want to make it well this is a virtual machine so we kind of deal in smaller numbers here so let's make this like a hundred megabytes what does that 320 doesn't matter okay so we have created a drive and I just left it at the name there for new hard drive because this is only for VirtualBox this name will not appear in anything that has to do with the operating system all right so we have our drive and the next thing that we're going to do is we're going to stick a bootable live Linux DVD or USB stick in this would be the same thing that you use to install Linux and I think what we'll do is we're going to do it with a boom to Nome just for fun so now we have our storage all figured out there so if this was a real machine I would have taken the case apart I would have put the new Drive in plugged it all in and then closed it back up and then stuck a USB stick in there that will boot it off of a live Linux environment you can do this from within the installed system you will have to install some software to do that but it's just easier just to boot off of a different system like a live disc to do it ok so now we have that so we'll go ahead and we will start up our machine and it is loading the live image of a boon to Nome even though this is a Linux Mint machine it's perfectly fine any live image will do most distributions of Linux that have some sort of live environment that you can boot into they will have the tools that you need installed in that live environment not necessarily once the system gets installed though all right so we are going to try a boon to now your particular live disc may go straight to a desktop or you may get some different stuff here but this is how it works if you're doing something in a boom tube and it's going to dump us out to a live desktop no we don't need to do that we can close that and we go to activities and the program that we need is gparted so we can get our new disc all formatted up and ready to rock and roll so when gparted opens up you're going to see probably the drive that the machine is booting off of first which would be dev SDA right here and you can see that we have partitions here here's the system this is the system and then there's a logical partition here that has a swap space for the virtual machine now we don't want to do anything to this drive we want to be very careful because if we would change anything about these partitions well we could Trash the whole system what we're going to be interested in is this drive which is the one we just created now since this is a virtual drive and I just created it it's totally blank there's nothing on it we're starting from scratch this would be like you went out to the big-box store and picked up a hard drive or ordered one online and it showed up and you took it out of the box and put it in the machine it's never had anything on it if you are going to be recycling a drive there's a couple of things to keep in mind here so if the drive came out of a Windows machine it's going to be formatted with NTFS yes you may be tempted to leave it at NTFS and then just go ahead and mount it into your system and use that as a data drive don't do it because NTFS has a habit of breaking itself and if you are not running NTFS in a Windows System that has the check disk utility that fixes those problems then your data may become corrupted over time using it on a Linux system also NTFS does not provide the right permissions for files the way Linux reads and writes in CFS is it essentially ignores those permissions completely so in that case it probably would be a better idea to go ahead and reformat that disk and then you could turn it into something that would be native to Linux which is what we're going to do today the next thing to consider is if you are using a disk that was used in a Linux system and you are now going to repurpose that disk to make it a data drive in this system what you may end up with is a situation where you will have to turn swap off so let's go back to the system drive here and you will see that we have a swap partition right here what the live system will do is when it boots up it scans for disks that have swap space and if they're swap space available it goes ahead and puts its own swap on that swap space if you were trying to work with that disk like reformat it or you were going to change the partitions the system wouldn't like that it wouldn't allow you to do it so what you do is just click on the swap partition and gparted and then choose swap off now that is off and if we wanted to reformat this particular drive we could but we're not because this is our system drive I'm just doing that to show you what the deal is if the live system puts it's the swap space virtual memory on the system drive that's no problem because ordinarily we wouldn't be messing with it anyway so the first thing that we need to do is create a new partition if there's already stuff on here still create a new partition start over so that we start with a clean slate and we will create a partition table and in this case it's prompting us that the partition table will be ms-dos we're going to stick with that for this video if it was a particularly large Drive and you were going to put a lot of little partitions on it then you might want to use GPT which doesn't have the restrictions of ms-dos the ms-dos partitioning system will allow you to create three primary partitions and then you have to create a logical partition and within those logical partitions you can create logical volumes so you can have more partitions but GPT doesn't bother with that and it supports bigger drives so in this case we have a pretty small Drive so we don't have to worry about that anything under two terabytes ms-dos will work just fine so we'll go ahead and create that so now we have created that and we need to put some partitions on here so let's do new and in this case for the purpose of this video I'm actually going to put two on here so let's just kind of split the drive down the middle a little bit and we're going to create the first partition which is going to be primary and we are going to call this partition music we want to use the ext4 filesystem that is native to most Linux distributions especially if you're working within a boom tube based distribution or arch linux this is what you want to be using for sure is the xp for and we want it to be a primary partition we'll go ahead and add it so that's the first one and click over here on this free space we're going to do another one and then this will be the rest of the disk right here primary once again xt4 yes and then we're going to call this one just data just data we're going to give that name data so what we now have is a disk with two partitions on it one of them is called music and one of them is called data now gparted hasn't actually done anything yet which is really cool so if you change your mind at this point you want to go back and change the size of the partitions you want to start over or you say I'm not going to use this drive and when you use this other drive whatever the deal is you can stop here you have to apply the changes to make gparted actually do the changes to the disk and it's going to warn you that if it does this it blow out any data on the disk we started with a clean disk so that's not an issue that will click apply now it's created the partitions and this disk is actually done so now we can go ahead and shut down the virtual machine so we can work with this in the operating system and figure out what we don't do with it so let's go ahead and just we'll just restart and wait a couple seconds here a lot of times in a virtual environment like this when you restart a live environment it'll just crash now this doesn't happen with Hardware very often but it does happen in VirtualBox and I think that's exactly what's happened here because nothing's going on so we see isn't drive spinning no it's not doing anything so let's go ahead and just close this and we'll just power off the machine it's not going to hurt anything at all for us to do that ok so we'll go back here and we'll check to see that it removed the boot device it did we wanted to make sure that the there wasn't a boot device in the virtual DVD or it would have booted back into that so we want to boot into the native operating system that's already on the computer and here we go all right go ahead and login and we're at the desktop now we're going to have to work with our new drive a little bit to get it useful so if I open up the home directory here you now see that we have two new entries under devices and get that out we can go ahead and make this full screen too it'll make it a little bit easier to work with and you guys can see what's going on a little better so now we have one called data and we have one called music and if we click on it we can get into that but look we have a problem we can't create any files or folders here so what good does this do well what we need to do at this point is to give ourselves permission to actually use the drive when we created this drive we did it with root user privileges so all of this now is owned by the root user and it's not giving us permission to create files in here on either partition so we're going to have to change that so we can actually get some use out of it and to do that it's actually really easy so what we're going to do is alternate an f2 which allows us to run a command and the command that we're going to use in Linux Mint is g:k sudo and then the file manager which is Nimmo if you are running ubuntu with another desktop your file manager might be Nautilus it could be kaha it could be soon R it could be not many others to choose from if you're running KDE then it's dolphin but in this case it's Nemo so hopefully you know what file manager you're running and then it's going to ask for permission until I guess so what we have here is we have a root file manager which means that we have access to everything on this system and not only that we will be able to modify anything on the system so this is cool but it's also a bit dangerous make sure that you know exactly what you're doing before you proceed you could very easily blow out system files here and we're going to go to we're going to find our drives and right now the only one showing is music I need to unmount it from here I'll wait so it is mounted so let's go ahead and unmount that for now and I'll go have mount them both up because we're going to have to do this to both of them so go down here mount data now music we did that in a regular this is a regular file manager just make sure you have mounted up to the system that's the point now click on music right click and you notice now we can create files here because we're running as the root user go to properties go to permissions and for music we're going to do something a little bit different than just giving ourselves permission we're actually going to change the owner so go up here to owner and then scroll through the list there's going to be a bunch of people up here and groups and whatnot just find yours just find you and there I am right there so this is going to be my drive nobody else's and I am going to change the ownership of that drive now for data I want to do something a little bit different here we're going to go to properties go to permissions and now we're going to leave this as root and we're just going to make it so that other people on the system can create and delete files okay because this particular partition is going to be available to everyone so go ahead and close and then we will close our root file manager unmount that now what we should have is when we remount these we should have complete permission so there they are let's see if we can get into data and create something yes we can create a new file or a new folder so we'll create that and then within that let's just create a file just so we have something to look at I don't have any templates set up on this machine so just an empty document and the same thing goes for music now you can leave this just exactly the way it is and what will happen is that anybody who logs into the system will have access to these and then they can click on them and mount them and unmount them if they choose to the only problem with doing this is that if you have a program like for instance on the music drive if you have a program that is going to be looking for music there and it's not mounted up you'll launch your program and then it'll go I can't find anything so what we now have to do is we can tell the system hey I want this to be available all the time and you don't have to do that I mean if this is just a drive that you're going to drag files to and store things on and maybe some other people are going to do the same thing then that's fine you can you can just leave it the way it is and you can mount it by hand and then unmount it but most folks out there will probably put things like music and video and other media stuff and stuff they want to get to with a program so it's better to have that mounted when the system boots up so we're going to do that right now and now is the time when we have to get into the terminal a little bit because it goes back to the nature of the way that Linux handles block storage devices and we got to get some information so we're going to open up a terminal and the first thing that we're going to do is we're going to run a command called block ID sudo CLF blk ID okay block ID now what this is going to do is it's going to give us the universal unique identifiers for all of the storage devices on the system and we're going to have to have those so we can make them mount automatically so we have music we have data and these are the uu IDs right here see those so we'll just leave that where it is right now I can just leave that terminal open and we'll kind of put it to the side a little bit and then we're going to use alternate f2 to make it so that we can open up a text editor and we're going to open it up with root privileges just like we did the file manager and in Linux Mint the graphic text editor is called X IDI so let's go ahead and do that so we're going to do GK sudo make sure I type that in correctly gk sudo x e d it's going to ask from password again so we can give it root privileges and now we have a root text editor running on the system right here so the first thing that we need to do is we need to find a file called FS tab so go to open and we are going to want to get into the file system so go to other locations go to computer and we are looking for a directory called Etsy et Cie we're wearing - where do you hide there it is listing it in Reverse for some reason alright so there's a file in here called FS tab so we need to find that actually you can just type FS and it'll go straight to it so there is our FS tab file that we will open that up yes and this is what it looks like now what this file does is it tells Linux what to do with the storage devices you have on the system it tells them where to mount them within the master file system so the file system on a Linux machine always starts out with a slash and then you can mount other storage devices anywhere within that system so it's an endless there's endless opportunity to mount things you can have different drives in different places you can also have network connections that show up as just drives and as far as the end user is concerned it's just another directory or folder on the system and that's what this does so the first thing that we need to do before we start messing around with this is we're going to have to save a backup copy because just add back on here to make a backup if we mess this up and the system does not boot we want to be able to get back to where we started from now how would you fix it if it didn't boot or something was wrong well the best way to do it is to boot off a live disk again and then open up a root file manager navigate to this file on the system that you're booting from and then just copy FS tab back to FS tab restart the system and everything should be hunky-dory okay all right so that's the first thing that we needed to do now we need to add our devices and tell the system where to mount them so the first one we're going to do is music now before we do that we're going to have to do a little prep so we're going to take a little detour here so I can show you how to do this properly and that is open a file manager now we're going to assume that if this were a machine that you were using here's your music folder okay there's nothing in it right now so I'm just going to create an empty document and I'm going to call it song just so that we have something to work with all right now you would have all of your music in here and let's say that you wanted to put all of your music on that external storage device the first thing that you need to do is kind of move it out of here so that we can make the music folder an empty one so create new folder and we're going to call this one music - that's just a temporary folder we're going to have here for a while so we'll open up this folder and then we're going to use the nifty split screen feature in Nemo you can also just open up another one if your file manager doesn't do this and then I'm going to go back to home here and I'm going to go back to open up music - there so we have music to hear and the original music here and now I'm just going to drag that over and this is what you would do with your music collection let's put it over there right there alright so we've done that we're good to go okay so we close that up now we can pick up where we left off here so go to music and then we have the UUID we need to copy this it's like so and I'm going to do it the more traditional way I know some of you linux folks are watching this going oh you could have just middle click i know the videos for newbies guys we're just introducing concepts so we come down to the bottom of the file we're going to start a new line here and we'll type in UUID and we're going to have the UUID equal that number we just copied make sure you get the right one now that's why we put labels on the partitions the next thing we're going to do is tell it where to mount so where is it going to mount we need it to be in home and we're going to put it in Jo we're going to put it in music all right ahead just tab here it's not going to line up perfectly on this example but it'll be fine and then we need to tell it what kind of file system the device has remember we made it ext 4 that's good and then we just tab over once again all you need to do is create spaces I know there's different spaces between these things here but really it's just looking for a space so you can just tab once and it works just fine so the next thing we do is need to tell the system what rules to use for this particular system and a file system and we're going to use defaults here I spelled that correctly that's fine defaults is a standard set of rules that works just fine in these situations ok and then you see these two things here it says dump and pass and for the dump that has to do with something that the deep system backup stuff we're going to leave that 0 which means just leave it alone don't miss with it and the rim tab over once again and now we're going to add the pass since this is ext4 wouldn't be nice if the system checked it at boot up to make sure the drive was ok before it mounted it when we want it to do that but we wanted to do it after it does the drive that has the entire operating system on it so that's going to be past 1 and anything after that will be passed to so we just did that so there's our first drive and it should be ready to go now remember we have two partitions so what we're going to need to do is figure out a place to mount our data partition now a lot of folks will tell you to put it in the media folder but what happens is with that is that you're going to have a mounted device on your desktop all the time which is really kind of a bummer so what you want to do is you want to figure out a place for this to go so once again we'll do GK pseudo this time around will open up Nemo which is the file manager again so now we're back to having a root file manager go to file system now be very careful here you don't want to accidentally modify something that's already here like your your Bend folder or et Cie or something like that okay we just want to create a new directory we're going to create a new one here and we're just going to be real creative and call it data okay so we've created that new directory in there go ahead and close that so now we have a place to stick our data drive so let's get our UUID for that and we will copy and we'll create a new line paste in that number and put a space here and we're going to mount this one at data alright just tab over one a couple times there to give us some space need to tell it what the file system is in this case it's going to be ext4 set our rules once again it's defaults set the dump to zero and set the path to two all right so now we need to save this now don't save it as don't make the mistake of now just hitting the Save button and then blowing out your backup okay actually go over here and we'll do save as and then all we got to do is take this bak and dot off the end and click Save and now we have modified our FS tab file that already exists please replace done okay so you can just reboot the system to see if it works but what I'm going to do is cheat a little bit and use this open terminal to run a command that will do the same thing so sudo mount a which basically I'm telling the system a read FS tab and mount anything up that's there well it did it you know I know it did it I got no output if I get no output I have no errors now you don't have to use that command this is not mandatory mandatory you can just reboot the system so let's go ahead and check and see what we got going on here okay so now in our home folder we should have lots of space in our music and we can see that we've mounted the new drive because we'll have space left see there you go yep it's working it's done what it's supposed to do so we can open up music too and we'll split the skin and let's see go to home and now I'm going to drag all of my music that I want to be on that drive over on to it and you notice that didn't disappear here that's because if you're dragging from one partition to the next it's not going to delete it you're not moving it you're copying it so if I open this up now you see that that's there and it's also over here so you can verify that now all right that's great I've got this where I need it to be go ahead and turn that off we'll go back to home and now we can just remove this folder that we created to temporarily store our music delete ok so what about the data partition that we did before where is that in the system okay go ahead that's not going to unmount see we can't do that because it is mounted when the system boots up if you want to amount it you're going to have to put in reap privileges all right what about that data partition we were talking about where is it well that partition is going to be in the file system and it's going to be under data so there it is and there's the folder that we created when we started and we do have access to that and we can delete yep so there you go now if it is unwieldy for you to navigate to that data folder which might do the case then there's something that we can do to make that really easy go to my computer here and we'll go to home and once again I'm going to use this split thing now if your file manager doesn't do that just open up another one and so we're going to open up the file system here well over here that's fine and now I'm going to take this and I'm going to center click on it I'm Center clicking which means that in my case I'm using the button that goes along the scroll wheel on the mouse you can also click the right and left button simultaneously and I'm dragging and now it's going to give me the ability to link it here so go ahead and create a link and so now you have a link to that drive there now this is a system folder that appears on anything that's mounted to the system which you don't have access to ok so don't worry about it this is just a system folder called lost-and-found and it's part of that thing that we set up when the system boots up it will scan the drive with fsck and make sure it's ok so what it's going to do with that is is that if it finds any file fragments that it can't figure out it will stick in in there but that is like very rare and if it does happen the file system is probably trashed anyway never had the system actually do it but that's what lost-and-found is about so just don't worry about that and you see that it's telling us that this is locked and we can't get to it and let's see let's go into music I don't think we'll have a lost-and-found in there but there you go might show up after you reboot the system there you go we have added a drive we have created partitions and we have added tons of storage space to our system and we have also set it up so that we have restricted access to the music just to us and we've also made it so any other user can actually get into this data partition here so we're good to go all right gang that's pretty much it for this video I hope it helps I hope it wasn't confusing and just to let you know yes you can do everything that I just did by actually just opening up a terminal and typing in commands matter of fact for me these days if I'm going to do work like this that's how I do it and before I close out the video I think I'll just restart this machine and make sure that it mounts up the way it's supposed to I know it will but we're just going to make sure that it's working the way it should also give us something to look at on the screen while I give you my final thoughts this is actually I realized that if you're used to like Windows where you just plug a drive in and it shows up with another letter that this is a little bit daunting at first but once you realize what it's doing and how robust it is to be able to specifically tell the system where to mount storage and it's going to be like that every time then you kind of get to the point where you see okay this is cool this is going to work every time that I boot up the machine and it's going to be predictable now they're showing music on here because we mounted this particular partition inside our folder how do you get rid of that if you want to well the best way to do it in Linux Mint is just to do this so we go into settings I personally wouldn't mind having that there it's not that big a deal to me but we'll go to settings and we'll go to desktop and this applies to other distros as well you'll just have to find the settings for this where is desktop it's in here somewhere well I can get to it this way too let me just go here and go to desktop settings I wasn't seeing that's probably right in front of my face you know how that is things tend to disappear okay so right here you can have it where it does not show mounted volumes on the desktop oh that goes away of course the only bad thing about that is is that if you plug a USB stick into the system and then it you know automatically mount set up then you won't see it but you can always get to your devices from here so whichever way you want to do that is perfectly fine and that's it thanks for watching the video do a pre she ate it checkout freedom penguin comm for lots of really cool stories about Linux check out easy Linux on the web made a lot of changes to the page and also check out easy Linux on Facebook if you happen to be a Facebook user we're getting a lot of followers over there and a lot of people are discovering Linux on Facebook so all of you Facebook haters out there going yeah that's the reason why it's there because guess what the non Linux folks they're on Facebook so we're going where they are so we can get their attention all right gang that's it talk to you again soon
Info
Channel: Joe Collins
Views: 85,127
Rating: 4.8364964 out of 5
Keywords: Linux, Tutorial, OS, Software, Computer, Laptop, Desktop
Id: AeR8Rk5LwWU
Channel Id: undefined
Length: 38min 25sec (2305 seconds)
Published: Wed Jun 28 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.