Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I made a partition like /part on my machine with some important data...

But I can't stand the name of it...

I want a clear solution to resolve it and change the name of it to for example /test...

As you see this is my /etc/fstab information:

# /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>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda5 during installation
UUID=a21a99c4-e5b4-4197-ac5e-80d0fab1f30c /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda6 during installation
UUID=2e37d833-ca34-4fa7-a5d8-a4423a5af9bc /home           ext4    defaults          0       2
# /part was on /dev/sda7 during installation
UUID=47e6e0b1-0e57-4184-a378-375b9ce315c5 /part           ext4    defaults          0       2
# swap was on /dev/sda1 during installation
UUID=485e9f78-4dce-4404-af4e-f43985525264 none            swap    sw                0       0

The point is: My information are important and I scare to manipulate it without being sure... I want a safe solution...

How is it possible?

Thank you in advance

share|improve this question
    
unclear what you are asking.Did you want to change /dev/sdax to /part like that? –  Avinash Raj Feb 15 at 18:18
    
no...I have /part dir in my machine but it relates to /dev/sdax..I want to rename /part to /test –  MortezaLSC Feb 15 at 18:24

4 Answers 4

up vote 1 down vote accepted
  • Unmount the partition:

    # umount /part
    
  • Rename the directory after making sure it's not mounted:

    # mountpoint /part &>/dev/null || mv /part /best_name_ever
    
  • Edit /etc/fstab to replace /part with /best_name_ever

  • Remount the partition:

    mount /best_name_ever
    

The # is of course meant to represent your root prompt, not actual input to be typed in.

To test the safety of this solution or any other one on dummy data

The following instructions are (in part) stolen from Virtual Filesystem: Building A Linux Filesystem From An Ordinary File.

  • Create an ordinary file with a size of 20 MB (for example):

    $ dd if=/dev/zero of=dummy_fs bs=1k count=20480 # 20480 = 20 * 1024
    
  • Create an ext4 filesystem on your file:

    $ /sbin/mkfs -t ext4 dummy_fs       
    mke2fs 1.42.5 (29-Jul-2012)
    dummy_fs is not a block special device.
    Proceed anyway? (y,n) y
    ... # Output of mkfs
    
  • Mount the filesystem image, create some dummy data on it and test the solution:

    # mkdir /tmp/testmount
    # mount -o loop dummy_fs /tmp/testmount
    # touch /tmp/testmount/{blah,bleh} # Create dummy data
    # ls /tmp/testmount
    blah bleh lost+found
    # umount /tmp/testmount
    # mountpoint /tmp/sexy_name &>/dev/null || mv /tmp/testmount /tmp/sexy_name
    # mount -o loop dummy_fs /tmp/sexy_name
    # ls /tmp/sexy_name # to ensure your data is intact:
    blah bleh lost+found
    
share|improve this answer

In GParted, Unmount it, and then you change the 'Label', which affects the given name and mount point.
So if I changed this partition label to 'Data', it would have the label/name 'Data', and the mountpoint would become /media/wmobbs/Data.

example

Labels work best without spaces, and any special characters.


If that does not work, change these lines in your /etc/fstab:

# /part was on /dev/sda7 during installation
UUID=47e6e0b1-0e57-4184-a378-375b9ce315c5 /part           ext4    defaults          0       2

to:

# /part was on /dev/sda7 during installation - mountpoint changed to /test
UUID=47e6e0b1-0e57-4184-a378-375b9ce315c5 /test           ext4    defaults          0       2

You can edit the file by running sudo nano /etc/fstab, then applying the above changes, and saving with Ctrl+O.
You then need to run sudo mkdir /test to create the needed folder - note that the folder needs to be empty.
You have to reboot for any changes to take effect

share|improve this answer
    
I unmounted it with gparted, then clicked on label and set test...then accepted it..but nothing changed:( –  MortezaLSC Feb 15 at 18:54
    
Try @psusi 's answer - /etc/fstab just changes the mount points etc, and should not harm your data - I'll expand on that in an edit. –  Wilf Feb 15 at 19:04
1  
Thank you...I next solution shouldn't I use mount and umount commands? –  MortezaLSC Feb 15 at 19:55
    
Yes, you can just run sudo umount /part and then sudo mount test rather than rebooting. And then sudo rmdir /part when you're happy. :) –  dannysauer Feb 15 at 20:13

If you created the partition and set up /etc/fstab to mount it in /part, and want it now to be mounted in /test, then create the /test directory, and change /etc/fstab, then unmount and remount it.

share|improve this answer
    
How can I change it, My data is important and I scare –  MortezaLSC Feb 15 at 18:27
    
@MortezaLSC, the same way you changed it the first time; with your favorite text editor. –  psusi Feb 15 at 20:52

You can mount the /dev/sda partition on the mount point /test. For an example, see http://www.thegeekstuff.com/2013/01/mount-umount-examples/

share|improve this answer
    
Welcome to Ask Ubuntu! Please don't add 'thanks' as answers. Invest some time in the site and you will gain sufficient privileges to upvote answers you like, which is the Ask Ubuntu way of saying thank you. –  fossfreedom Feb 16 at 13:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.