LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-03-2017, 10:17 PM   #1
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,283

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Question: Unmounting /boot after reboot


I have a question on mounting /boot, or rather, unmounting it (or better, preventing it from being mounted) after control is transferred to the root filesystem.

This is on a Raspberry Pi 3 ("RPi") running Raspbian (a Debian Jessie derivative), but it is not specific to the RPi, it's more of a general Linux question.

My RPi has the minimal files needed for booting on it's MicroSD card (RPi's normally boot and run from Flash). I have an external USB HDD that holds the root filesystem and user data. After booting, /boot is no longer needed and I want it unmounted to protect the flash card from corruption (this corruption frequently happens on a RPi if it looses power). Currently, I am unmounting it manually.

The RPi can boot directly from USB without using the flash card normally, but not in my circumstance, otherwise that is the way I would have done this. My external drive is 4Tb, thus is requires GPT. But the RPi only understands MBR during boot, so it can't recognize my GPT drive. The RPi can deal with GPT, but ONLY after it has successfully booted from MBR.

Below is what the RPi looks like after booting (I use "df" to show the mounts because I like the layout of the display better than "mount"). Note that /dev/mmcblk0p1 is mounted on /media/pi/boot. That's what I want to prevent. It is not needed after booting (except during upgrades or config changes, but I understand that).

Code:
root@raspberrypi:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       9.5G  5.4G  3.7G  60% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M   36K  463M   1% /dev/shm
tmpfs           463M  6.4M  457M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
tmpfs           463M     0  463M   0% /var/tmp
tmpfs           463M  4.0K  463M   1% /tmp
/dev/sda2       3.6T   68M  3.4T   1% /user_data
tmpfs            93M  4.0K   93M   1% /run/user/1000
/dev/mmcblk0p1   66M   21M   46M  31% /media/pi/boot
root@raspberrypi:~#
I assume this is udev, systemd or something similar that is mounting this after boot. How do I prevent that from happening? If I can't prevent it in the first place, my other option is to have a script unmount it after the fact. I must ashamedly admit that my brain still works back in the old sysvinit days as far as startup scripts go, and I'm not sure where the best place to run an unmount script after boot would be these days. Any pointers on where/how to invoke a startup script to do this would be appreciated.

Note: The root filesystem above is mounted from "/dev/root". For some reason unknown to me, that is what the RPi calls it. I think that's a poor choice, because you don't know where it is coming from. Most other systems would call it "/dev/sda1", since it's coming from my external HDD.

Thanks in advance!
 
Old 05-03-2017, 10:48 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 18,500

Rep: Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101Reputation: 3101
Couple of options:
- if you can bust that user_data so it mounts on 2 mount-points you can probably use MBR on the 4T. Just make both partitions less than 2T - strictly speaking the last partition needs to start before the 2T mark, and be less than 2T in size. Works on my 3T anyway ....
- otherwise use a systemd timer pop to run the umount - say 2 minutes after boot. See "man systemd.timer".
- fix udev. I don't use Raspian, but on Arch the rules are in the normal place(s).
 
Old 05-05-2017, 04:50 AM   #3
mrmazda
Senior Member
 
Registered: Aug 2016
Location: USA
Distribution: openSUSE, Debian, Knoppix, Mageia, Fedora, others
Posts: 2,199

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
Have you tried creating an fstab entry for it using ro and/or noauto options?
 
Old 05-05-2017, 10:32 AM   #4
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,283

Original Poster
Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
There currently is NO fstab entry for this device at all. Do you think ADDING a new entry can be used to stop it's mounting? That seems unlikely to me. Especially since it's being mounted in /media/<username>
 
Old 05-05-2017, 01:42 PM   #5
mrmazda
Senior Member
 
Registered: Aug 2016
Location: USA
Distribution: openSUSE, Debian, Knoppix, Mageia, Fedora, others
Posts: 2,199

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
Quote:
Originally Posted by haertig View Post
Do you think ADDING a new entry can be used to stop it's mounting?
That's precisely why I wrote what I wrote. It's important to use option noauto, and preferable to use volume label to mount by.
 
Old 05-05-2017, 04:24 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,283

Original Poster
Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by mrmazda View Post
That's precisely why I wrote what I wrote.
Well, you were certainly right! Worked perfectly. I should not have doubted. Thank you very much for the suggestion. Trivially easy to implement.
 
Old 05-05-2017, 06:56 PM   #7
mrmazda
Senior Member
 
Registered: Aug 2016
Location: USA
Distribution: openSUSE, Debian, Knoppix, Mageia, Fedora, others
Posts: 2,199

Rep: Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702Reputation: 702
Nice!

Revisiting your original goal, you might want to consider mounting it elsewhere than /boot/ (e.g. /mnt/boot/), and leaving /boot/ as a mountpoint empty. That way, when updates need to write to /boot/, they can proceed normally, without you having to think ahead and take appropriate action. Then when updates are done, you can sync the changes manually at your leisure, needing first only to remount the MicroSD card rw.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unmounting all nfs filesystems without unmounting local ones kaplan71 Linux - General 1 03-05-2009 12:00 PM
[linux auto reboot] content"reboot system boot" hunter_cao7 Linux - Server 1 11-12-2007 07:09 PM
Reboot question kbrooks78 Fedora 2 10-27-2004 05:33 PM
quick question - mounting/unmounting drives tw001_tw Linux - Software 2 05-13-2004 09:09 PM
Question about reboot!!!!!!! septanla Linux - Software 6 04-29-2004 03:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration