Linux mount при загрузке

How to make partitions mount at startup?

How do you make HDDs and partitions mount at startup on Ubuntu? I always keep my media and data files on separate partitions — one 2tb HDD and a 400 odd gig partition. I have been trying to swap the default folder location for the home directory to my other drives. It works when I change the /home/user_name/.config/user-dirs.dirs file to the directories I want, but only until I reboot the system. I am only assuming that the drives not mounting is the problem with it, but it would be helpful either way. If any one knows another reason for why the directories change back to default each time that would be good also.

Edit the /etc/fstab file, here are useful links that has answers to your question: mount a drive on startup and mount ntfs drive on startup.

7 Answers 7

GUI Method (recommended for newbies) — The Disks program will automatically edit /etc/fstab for you and not break anything. Type disks on the launcher or gnome-disks in the terminal start the Disks application.

Select Drive, then partition, then use More actions (cogs icon) button to access ‘Edit Mount Options’ menu. Turn off User Defaults because you would not be here if it was really set to automount. The rest should be obvious.

Disks application Disks application - cogs icon menu, about to click Edit Mount Options. Disks application - Mount Options dialog

Just don’t forget to uncheck «Automatic mount options». I was confused because auto-mount was not working even though the «Mount at startup» checkbox was checked in the grayed out UI.

Terminal Method for experienced users only. This can break your boot.
If you are okay with this, fire up a terminal.

  1. [IMPORTANT] sudo cp /etc/fstab /etc/fstab.old — Create a backup of the fstab file just in case something unwanted happens. If something happens, you will need a bootable (live) usb. If you do not have one, use the GUI method instead.
  2. sudo blkid — Note the UUID of the partition you want to automount.
  3. sudo nano /etc/fstab — Copy the following line to the end of the file, save it and reboot afterwards to check if it worked.
  4. mkdir /my/path/tomount # to quote : «you must create the mount point before you mount the partition.» see https://help.ubuntu.com/community/Fstab
Читайте также:  Мой ip linux terminal

Examples

Use lsblk -o NAME,FSTYPE,UUID to find out the UUIDs and filesystems of the partition you want to mount. For example:

$ lsblk -o NAME,FSTYPE,UUID NAME FSTYPE UUID sda ├─sda2 ├─sda5 swap 498d24e5-7755-422f-be45-1b78d50b44e8 └─sda1 ext4 d4873b63-0956-42a7-9dcf-bd64e495a9ff 

NTFS

UUID=  ntfs uid=,gid=,umask=0022,sync,auto,rw 0 0 

Examples for the <> variables:

  • = 3087106951D2FA7E
  • = /home/data/ # create this before rebooting
  • = 1000
  • = 1000

Use id -u to get the userid and id -g to get the groupid.

(Note that specifying the sync option can slow down write performance as it disables the cache. async is the default.)

Screenshot of my computer's _fstab_ file

Careful about being too prescriptive with the mount options; not everybody’s uid & gid will be the default 1000.

@bbodenmiller sync option should be avoided here. It slows down disk writes because you ask for every byte to be flushed instantly instead of letting your computer optimize that for you. The answer should remove sync

I read in man mount that in the case of media with a limited number of write cycles (e.g. some flash drives), sync may cause life-cycle shortening.

In Ubuntu follow these steps to auto-mount your partition:

  1. Open file manager and look left side on the devices listed.
  2. Choose the device you want to auto-mount on start-up by just clicking it and you will see the folders in the right pane shown for that device (partition), keep this window open.
  3. Go to your desktop Ubuntu search and type disks, you’ll see disks shown in results.
  4. Click on disks and disks manager will start.
  5. You will see HDD’s listed on the left pane and details of partitions on the right pane for each HDD you have.
  6. Now highlight the partition by clicking it, IMPORTANT (don’t set mount on start-up for all partitions as it slows down the system).
  7. Make sure that the partition name you want to auto-mount have the same name by comparing the partitions in disk manager with the open partition window which you opened previously, by looking at the name of device at the top-left part of file manager (opened earlier), and looking the same name of drive or partition in the disks manager at the Contents field of the chosen partition in disks manager.
  8. Now after making sure that you have chosen the correct partition, in disks manager just click more actions icon, sub-menu list will open, choose edit mount options, mount options will open with Automatic mount options = ON, so you turn this off and by default you’ll see that mount at start-up is checked and show in user interface is checked, then hit OK and restart your system, after log-in go to file manager you’ll see the part you choose to mount at start-up is already mounted.
Читайте также:  Linux eof to file

@dstonek — You have option to specify Mount Point in the Edit Mount Options at the step 8 above . That is, you can tell it to mount in /dev if you want it there..

When the system boots, it checks the file /etc/fstab (which stands for «filesystem table») for the list of partitions to mount automatically.

The syntax of a fstab entry is :

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]

You can add your own entries, but you’ll need to know the device path (eg, /dev/sdb1), or their UUID (a big long string of numbers) to identify them.

Though a link may theoretically solves the problem, it’s a good practice to include essential part in the question

echo '/dev/[VolumeGroup]/[VolumeName] [custom-directory] ext4 defaults 0 2' >> /etc/fstab 
echo '/dev/hdd/hdd /mnt/hdd ext4 defaults 0 2' >> /etc/fstab echo '/dev/ssd/ssd /mnt/ssd ext4 defaults 0 2' >> /etc/fstab 

All the answers use a GUI tool, or /etc/fstab . My problem with these is that I run headless servers (no GUI) and, most importantly, that I am usually mounting secondary USB hard-drives, where fstab will prevent your system from booting up if the drive is missing, damaged, etc. This has happened to me in the past, and it has left stranded otherwise perfectly functioning systems.

My solution is to use cron . In particular, add this line to your crontab -e with the specific info of your system.

@reboot mount /dev/sdX /mnt/my-usb/ 

With this, cron will try and mount your drive upon every system start.

Warning: this relies on /dev/sdX to remain unchanged through reboots, which is not guaranteed. In other words, the drive under /dev/sda might become /dev/sdb on the next boot. But in my non-professional setting, it’s been working.

Читайте также:  Настройка линукс нет русского

If you need more reliability, you can create a shell or python script to search for the right /dev/sdX based on the serial number, and then mount it, and execute the script with cron and the @reboot trigger.

Источник

How to mount a new drive on startup [duplicate]

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) — but did not create a partition (is this advisable?). I have manually mounted the drive as /mydata. I want to have the machine automatically mount the device on startup/reboot. How may I do this? [[Update]] This is the output from running sudo fdisk -l on my system:

Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000858bf Device Boot Start End Blocks Id System /dev/sda1 * 1 59334 476595200 83 Linux /dev/sda2 59334 60802 11789313 5 Extended /dev/sda5 59334 60802 11789312 82 Linux swap / Solaris Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table Disk /dev/sdc: 16.0 GB, 16026435072 bytes 254 heads, 63 sectors/track, 1956 cylinders Units = cylinders of 16002 * 512 = 8193024 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdc1 1 1955 15641929 c W95 FAT32 (LBA) 

Источник

Оцените статью
Adblock
detector