Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

mounting a drive regardless of if you move it


  • Please log in to reply
20 replies to this topic

#1 bmike1

bmike1

  • Members
  • 596 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Gainesville, Florida, USA
  • Local time:07:07 PM

Posted 01 January 2015 - 01:56 AM

There was discussion  regarding UUIDs. A couple of us believed that if you mount something by it's UUID it would mount regardless of if other partitions had been inserted into the directory tree or not. Luckily, Hollowface test that belief out and it was proven to be untrue. I was discussing this with my local LUG and one of the users said:
 
/boot/grub/device.map keeps things mapped by logical location and uuid.  if you created a new partition, even if it had the same UUID, it would have a different logical address.
 
now don't go looking for the address because it isn't on a linux system but we can get the gist of his instructions. Later he said:
 
Welp, I went and installed a linux mint vm and see that grub.cfg has the root pointed at hd0 and a big fat UUID.  Gotta love it.  The lesson here is if you're playing with your partitions, rerun the grub stuffs.
 
Then another member said:
 
For legibility and clarity, I think it's better to use filesystem labels instead of UUIDs when mounting stuff.
 
I then remembered that some time ago I was mounting via labels  and that it was much easier to mount things by typing 'mount -L <label> /mnt/<label>' than it was to type out 'mount /dev/hda1 /mnt/hda1'. If you want to investigate this and test it for yourself 'man mount' '/label' (and a little searching) shows:
 
       -L label
              Mount the partition that has the specified label.
 
But then, as I was searching man just now, I think I found why it failed:
 
       Mount by label or uuid will work only if your devices  have  the  names
       listed  in  /proc/partitions.   In  particular, it may well fail if the
       kernel was compiled with devfs but devfs is not mounted.
 
 
It must not have had that bug when I was using labels. Someone needs to test this. I need to get off of the computer.

 


A/V Software? I don't need A/V software. I've run Linux since '98 w/o A/V software and have never had a virus. I never even had a firewall until '01 when I began to get routers with firewalls pre installed. With Linux if a vulnerability is detected a fix is quickly found and then upon your next update the vulnerability is patched.  If you must worry about viruses  on a Linux system only worry about them in the sense that you can infect a windows user. I recommend Linux Mint or, if you need a lighter weight operating system that fits on a cd, MX14 or AntiX.


BC AdBot (Login to Remove)

 


#2 Al1000

Al1000

  • Global Moderator
  • 7,975 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:12:07 AM

Posted 01 January 2015 - 06:12 AM

How would you mount a partition by its UUID, when it's not listed in /dev by the UUID?

For example: (using Puppy so there is no sudo command)

# blkid
/dev/loop0: TYPE="squashfs" 
/dev/loop1: UUID="81200825-ccb6-4370-9e04-dbf763b0dbb6" TYPE="ext3" 
/dev/sda1: LABEL="/" UUID="2639-4A0E" TYPE="vfat" 
/dev/sda5: LABEL="Puppy" UUID="0a86140e-c4ec-4842-b2e0-7eb8c76b3a4e" TYPE="ext4" /dev/sda6: UUID="b6455bbc-9451-47f1-b0bb-2f6bdbb7d2fe" TYPE="swap" 
/dev/sda7: LABEL="Kubuntu" UUID="c3401d73-0c85-43ba-abf5-dc18b525f3e7" TYPE="ext4" 
/dev/sda8: LABEL="Files" UUID="dfb4fb3b-b012-4f41-8bad-c563492a9f99" TYPE="ext4" /dev/loop4: TYPE="squashfs" 
# mount -L 2639-4A0E /mnt/sda1
mount: no such partition found
# 
I thought it was only possible to mount partitions as they are listed in /dev

For example:

mount /dev/sda1 /mnt/sda1
... is how I would mount that partition to /mnt/sda1 using the terminal.

Is there another way of doing so?

Edited by Al1000, 01 January 2015 - 06:19 AM.


#3 bmike1

bmike1
  • Topic Starter

  • Members
  • 596 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Gainesville, Florida, USA
  • Local time:07:07 PM

Posted 01 January 2015 - 02:26 PM

yeah.... I think that the problem is the uuid/labels aren't listed in /proc/partitions. I'll ask around and see if anyone knows how to add the uuid/labels to /proc/partitions. I think (until they fix this bug) that you may have to open /proc/partitions with a text editor and physically add it. I'd test it but I don't have a test computer.

 

You know.... it is strange that they came out with UUID and label yet linux still defaults  to /dev/<whatever> .


Edited by bmike1, 01 January 2015 - 02:43 PM.

A/V Software? I don't need A/V software. I've run Linux since '98 w/o A/V software and have never had a virus. I never even had a firewall until '01 when I began to get routers with firewalls pre installed. With Linux if a vulnerability is detected a fix is quickly found and then upon your next update the vulnerability is patched.  If you must worry about viruses  on a Linux system only worry about them in the sense that you can infect a windows user. I recommend Linux Mint or, if you need a lighter weight operating system that fits on a cd, MX14 or AntiX.


#4 cat1092

cat1092

    Bleeping Cat


  • BC Advisor
  • 7,018 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:North Carolina, USA
  • Local time:07:07 PM

Posted 01 January 2015 - 04:06 PM

What Al1000 told me awhile back worked for me, I used GParted in Live Mode to expand my /home partition from 100MiB to 175MiB, rebooted, and the space was there. Didn't have to reboot either. 

 

I didn't think that Linux partitions could be moved or resized, but they can be. I've even added a Swap partition with it on another computer, and there was a trick to turn it on in the drop menu. 

 

Cat


Performing full disc images weekly and keeping important data off of the 'C' drive as generated can be the best defence against Malware/Ransomware attacks, as well as a wide range of other issues. 


#5 Al1000

Al1000

  • Global Moderator
  • 7,975 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:12:07 AM

Posted 01 January 2015 - 06:03 PM

yeah.... I think that the problem is the uuid/labels aren't listed in /proc/partitions. I'll ask around and see if anyone knows how to add the uuid/labels to /proc/partitions. I think (until they fix this bug) that you may have to open /proc/partitions with a text editor and physically add it. I'd test it but I don't have a test computer.

 

I've now had a look at man mount. You might also have noticed it says:

 

-L label
              Mount the partition that has the specified label.

       -U uuid
              Mount the partition that has the specified uuid.  These two options require the file  /proc/par‐
              titions (present since Linux 2.1.116) to exist.

 

Here is my /proc/partitions file:

 

major minor  #blocks  name

   8        0  488386584 sda
   8        1  102400000 sda1
   8        2          1 sda2
   8        5   20480000 sda5
   8        6    4194304 sda6
   8        7   49517568 sda7
   8        8  311789568 sda8
  11        0     436474 sr0
   8       16   15633408 sdb
   8       17   15632384 sdb1

 

...yet I cannot get either command to work.

 

al@my_desktop_pc:~$ sudo mount -L sda5 /mnt/sda5
mount: no such partition found

 

Editing /proc/partitions with a text editor results in a warning that the file has changed since it was opened when I try and save it, and then an I/O error if I proceed. I guess it must be one of these files that the system generates when it boots up, and isn't supposed to be manually edited.

 



#6 NickAu

NickAu

    Bleepin' Fish Doctor


  • Moderator
  • 13,556 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:127.0.0.1 Australia
  • Local time:10:07 AM

Posted 01 January 2015 - 07:04 PM

 

Editing /proc/partitions with a text editor results in a warning that the file has changed since it was opened when I try and save it,

/proc/partitions shows you the partitions you have. You don't change it directly.

 

 

fstab is a configuration file that contains information of all the partitions and storage devices in your machine. The file is located under /etc, so you need root to edit it.

gksu gedit /etc/fstab

Might be of use.


Edited by NickAu, 02 January 2015 - 12:24 AM.


#7 bmike1

bmike1
  • Topic Starter

  • Members
  • 596 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Gainesville, Florida, USA
  • Local time:07:07 PM

Posted 02 January 2015 - 01:56 AM

This also from man mount:

 

     In  particular, [label mounting] may well fail if the kernel was compiled with devfs but devfs is not mounted.

A/V Software? I don't need A/V software. I've run Linux since '98 w/o A/V software and have never had a virus. I never even had a firewall until '01 when I began to get routers with firewalls pre installed. With Linux if a vulnerability is detected a fix is quickly found and then upon your next update the vulnerability is patched.  If you must worry about viruses  on a Linux system only worry about them in the sense that you can infect a windows user. I recommend Linux Mint or, if you need a lighter weight operating system that fits on a cd, MX14 or AntiX.


#8 bmike1

bmike1
  • Topic Starter

  • Members
  • 596 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Gainesville, Florida, USA
  • Local time:07:07 PM

Posted 02 January 2015 - 02:00 AM

-L label
              Mount the partition that has the specified label.

       -U uuid
              Mount the partition that has the specified uuid.  These two options require the file  /proc/par‐
              titions (present since Linux 2.1.116) to exist.

We just need to find out how to add the label/uuid to /proc/partitions and we'll all be happy campers!


A/V Software? I don't need A/V software. I've run Linux since '98 w/o A/V software and have never had a virus. I never even had a firewall until '01 when I began to get routers with firewalls pre installed. With Linux if a vulnerability is detected a fix is quickly found and then upon your next update the vulnerability is patched.  If you must worry about viruses  on a Linux system only worry about them in the sense that you can infect a windows user. I recommend Linux Mint or, if you need a lighter weight operating system that fits on a cd, MX14 or AntiX.


#9 NickAu

NickAu

    Bleepin' Fish Doctor


  • Moderator
  • 13,556 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:127.0.0.1 Australia
  • Local time:10:07 AM

Posted 02 January 2015 - 02:16 AM

How to fstab - Ubuntu Forums

 

UsingUUID - Community Help Wiki

 

 

[SOLVED] How To Add or Auto Mount Linux Partitions fstab with .


Edited by NickAu, 02 January 2015 - 02:19 AM.


#10 Al1000

Al1000

  • Global Moderator
  • 7,975 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:12:07 AM

Posted 02 January 2015 - 08:07 AM

fstab is a configuration file that contains information of all the partitions and storage devices in your machine. The file is located under /etc, so you need root to edit it.

 

fstab only seems to contain information regarding partitions that are normally mounted at boot. For example here is the fstab file on a live DVD that I'm using:

 

mint@mint ~ $ cat /etc/fstab
overlayfs / overlayfs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
/dev/sdb6 swap swap defaults 0 0

 

... which in this instance is just swap.

 

I also thought that editing fstab was how you set the computer to automount additional partitions at startup, but can't say for sure as I don't think I've ever tried editing it.



#11 Al1000

Al1000

  • Global Moderator
  • 7,975 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:12:07 AM

Posted 02 January 2015 - 08:09 AM

We just need to find out how to add the label/uuid to /proc/partitions and we'll all be happy campers!

 

Doesn't it already contain the label (sda1, etc), under 'name'?


Edited by Al1000, 02 January 2015 - 08:10 AM.


#12 bmike1

bmike1
  • Topic Starter

  • Members
  • 596 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Gainesville, Florida, USA
  • Local time:07:07 PM

Posted 02 January 2015 - 12:10 PM

it doesn't have the uuid or label there. sda1 is not a label. I believe it is called the device designation. Really I just made 'device designation' up but it sounds good to me! I just created the label with the command 'e2label' and just tried mounting by UUID and the label and the mount was a success:

 

bmike1@c521 ~ $ sudo mount -U f35e1797-4cdb-4930-a740-b424afbf61c7 /mnt/a
bmike1@c521 ~ $ sudo e2label /dev/sda1 mint
bmike1@c521 ~ $ sudo mount -L mint /mnt/a
bmike1@c521 ~ $ 
 
the problem, I discovered, was that /mnt has nothing in it. I just had to mkdir and everything works.

Edited by bmike1, 02 January 2015 - 03:28 PM.

A/V Software? I don't need A/V software. I've run Linux since '98 w/o A/V software and have never had a virus. I never even had a firewall until '01 when I began to get routers with firewalls pre installed. With Linux if a vulnerability is detected a fix is quickly found and then upon your next update the vulnerability is patched.  If you must worry about viruses  on a Linux system only worry about them in the sense that you can infect a windows user. I recommend Linux Mint or, if you need a lighter weight operating system that fits on a cd, MX14 or AntiX.


#13 pcpunk

pcpunk

  • Members
  • 6,100 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:07:07 PM

Posted 02 January 2015 - 02:50 PM

I'm reading guys but it's over my head, lol.  Good to see all the work you are doing though.


sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 


#14 DeimosChaos

DeimosChaos

  • BC Advisor
  • 1,420 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:United States, Delaware
  • Local time:07:07 PM

Posted 02 January 2015 - 03:08 PM

I just recently mounted a drive with its UUID. My server had failed and I needed to grab the info off of it. So I hooked it up externally and was having all sorts of issues getting it recognized since it was a LVM format partition. All I could see was the grub boot menu when it was hooked up. Turns out I needed to install the package "lvm2" (debian systems) and then I found this guide to get the drive mounted. I can't remember if I did all the steps, since the person that wrote it was using Fedora I had to do some different things since I was on debian. But it helped me successfully mount the drive and get my data.


OS - Ubuntu 14.04/16.04 & Windows 10
Custom Desktop PC / Lenovo Y580 / Sager NP8258 / Dell XPS 13 (9350)
_____________________________________________________
Bachelor of Science in Computing Security from Drexel University
Security +


#15 NickAu

NickAu

    Bleepin' Fish Doctor


  • Moderator
  • 13,556 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:127.0.0.1 Australia
  • Local time:10:07 AM

Posted 02 January 2015 - 05:08 PM

 

For example here is the fstab file on a live DVD that I'm using:

 

 

And here's  one  from an installed system. Live boot don't count

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=220e4c76-a7a4-4ac5-9697-b4052c220660 /               ext4   noatime,errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=C911-3A51  /boot/efi       vfat    defaults        0       1
# swap was on /dev/sda3 during installation
UUID=e5e485a1-ac2d-4748-833f-bee406ef2ee3 none            swap    sw              0       0

70gvoj.png


Edited by NickAu, 02 January 2015 - 05:23 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users