{"id":1504,"date":"2019-11-02T23:58:03","date_gmt":"2019-11-02T21:58:03","guid":{"rendered":"https:\/\/helia.ee\/koolitus\/?page_id=1504"},"modified":"2019-11-02T23:58:03","modified_gmt":"2019-11-02T21:58:03","slug":"debian-how-to-mount-a-new-drive-on-startup-fstab","status":"publish","type":"page","link":"https:\/\/helia.ee\/koolitus\/?page_id=1504","title":{"rendered":"Debian &#8211; How to mount a new drive on startup (fstab)"},"content":{"rendered":"<p>This question already has an answer here:<\/p>\n<p>How to make partitions mount at startup? 6 answers<br \/>\nI have recently installed a new hard drive to my Ubuntu 10.0.4 box. I used System -> Administration -> Disk Utils to format the disk (ext4 file type) &#8211; but did not create a partition (is this advisable?).<\/p>\n<p>I have manually mounted the drive as \/mydata.<\/p>\n<p>I want to have the machine automatically mount the device on startup\/reboot. How may I do this?<\/p>\n<p>[[Update]]<\/p>\n<p>This is the output from running sudo fdisk -l on my system:<\/p>\n<p>Disk \/dev\/sda: 500.1 GB, 500107862016 bytes<br \/>\n255 heads, 63 sectors\/track, 60801 cylinders<br \/>\nUnits = cylinders of 16065 * 512 = 8225280 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0x000858bf<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<br \/>\n\/dev\/sda1   *           1       59334   476595200   83  Linux<br \/>\n\/dev\/sda2           59334       60802    11789313    5  Extended<br \/>\n\/dev\/sda5           59334       60802    11789312   82  Linux swap \/ Solaris<\/p>\n<p>Disk \/dev\/sdb: 500.1 GB, 500107862016 bytes<br \/>\n255 heads, 63 sectors\/track, 60801 cylinders<br \/>\nUnits = cylinders of 16065 * 512 = 8225280 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0x00000000<\/p>\n<p>Disk \/dev\/sdb doesn&#8217;t contain a valid partition table<\/p>\n<p>Disk \/dev\/sdc: 16.0 GB, 16026435072 bytes<br \/>\n254 heads, 63 sectors\/track, 1956 cylinders<br \/>\nUnits = cylinders of 16002 * 512 = 8193024 bytes<br \/>\nSector size (logical\/physical): 512 bytes \/ 512 bytes<br \/>\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes<br \/>\nDisk identifier: 0x00000000<\/p>\n<p>   Device Boot      Start         End      Blocks   Id  System<br \/>\n\/dev\/sdc1               1        1955    15641929    c  W95 FAT32 (LBA)<br \/>\nfstab<br \/>\nshareimprove this question<br \/>\nedited May 13 &#8217;13 at 15:00<\/p>\n<p>Suhaib<br \/>\n3,42255 gold badges3131 silver badges4545 bronze badges<br \/>\nasked Jun 21 &#8217;12 at 14:59<\/p>\n<p>Homunculus Reticulli<br \/>\n99233 gold badges1818 silver badges2222 bronze badges<br \/>\nmarked as duplicate by Ciro Santilli \u65b0\u7586\u6539\u9020\u4e2d\u5fc3\u6cd5\u8f6e\u529f\u516d\u56db\u4e8b\u4ef6, Eric Carvalho, user117103, waltinator, ravery Nov 25 &#8217;17 at 4:38<br \/>\nThis question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.<\/p>\n<p>there&#8217;s a disks utility in 12.04 &#8230; have a look you may find one in your version. It allows you to edit mount option on a partition there&#8217;s one for startup \u2013 Merlin Jun 21 &#8217;12 at 15:51<br \/>\nadd a comment<br \/>\n8 Answers<br \/>\nactiveoldestvotes<\/p>\n<p>83<\/p>\n<p>First of all your \/dev\/sdb isn&#8217;t partitioned. I am assuming this is the disk you want to mount.<\/p>\n<p>WARNING: THIS WILL DESTROY ANY DATA ON YOUR TARGET DISK<br \/>\nRun sudo fdisk \/dev\/sdb<\/p>\n<p>Press O and press Enter (creates a new table)<\/p>\n<p>Press N and press Enter (creates a new partition)<\/p>\n<p>Press P and press Enter (makes a primary partition)<\/p>\n<p>Then press 1 and press Enter (creates it as the 1st partition)<\/p>\n<p>Finally, press W (this will write any changes to disk)<\/p>\n<p>Okay now you have a partition, now you need a filesystem.<\/p>\n<p>Run sudo mkfs.ext4 \/dev\/sdb1<\/p>\n<p>Now you can add it to fstab<\/p>\n<p>You need to add it to \/etc\/fstab use your favourite text editor<\/p>\n<p>Be careful with this file as it can quite easily cause your system not to boot.<\/p>\n<p>Add a line for the drive, the format would look like this.<\/p>\n<p>This assumes the partition is formatted as ext4 as per mkfs above<\/p>\n<p>#device        mountpoint             fstype    options  dump   fsck<\/p>\n<p>\/dev\/sdb1    \/home\/yourname\/mydata    ext4    defaults    0    1<br \/>\nThen on the next reboot it will auto mount.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This question already has an answer here: How to make partitions mount at startup? 6 answers I have recently installed a new hard drive to my Ubuntu 10.0.4 box. I used System -> Administration -> Disk Utils to format the disk (ext4 file type) &#8211; but did not create a partition (is this advisable?). I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":621,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1504","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1504"}],"version-history":[{"count":1,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1504\/revisions"}],"predecessor-version":[{"id":1505,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/1504\/revisions\/1505"}],"up":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/621"}],"wp:attachment":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}