LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can I make these commands shorter? (https://www.linuxquestions.org/questions/linux-newbie-8/can-i-make-these-commands-shorter-4175416597/)

imayneed 07-13-2012 06:50 PM

Can I make these commands shorter?
 
I need to make this commands shorter to pass through Grub's 256 byte limit.

sudo su -
rm -r /home/partimag
mkdir -p /home/partimag
mkdir -p /tmp/local_dev
ntfs-3g /dev/sdb2 /tmp/local_dev
mount --bind tmp/local_dev/Clones /home/partimag

Unfortunately /home/partimag has to be deleted and then created.

I am trying to accomplish mounting sdb2/Clones as /home/partimag (where sdb2 is NTFS).

Is there anyway to make these commands shorter?

rch 07-13-2012 07:02 PM

So you want /home/partimag to be deleted on each boot - correct? Add your commands at the end of rc.local file. As for mounting ntfs partition, just add them to /etc/fstab.

towheedm 07-13-2012 07:18 PM

These are all shell commands. What does it have to do with your bootloader?

Nonetheless, why delete /home/partimag and then re-create it. Keep the /home/partimag directory and delete everything else under it.
Code:

rm -r /home/partimag
mkdir -p /home/partimag

# Use one command instead:
rm -r /home/partimag/*    # This deletes everything under /home/partimag, but keeps /home/partimag

Or, combine the two mkdir commands into one command:
Code:

mkdir -p /home/partimag /tmp/local_dev

imayneed 07-13-2012 09:41 PM

Combining mkdir helps. Thank you.

What if I use /mnt instead of /tmp/local_dev? It didn't cause any problem with the booting.

I changed the codes to

sudo su -
rm -r /home/partimag
mkdir -p /home/partimag
ntfs-3g /dev/sdb2 /mnt
mount --bind /mnt/Clones /home/partimag

And it still worked. This way I didn't have to create /mnt and /mnt is much shorter than /tmp/local_dev.
Since I don't know have much knowledge, I was worried that mounting to /mnt could cause problems.

Thanks again.

towheedm 07-14-2012 01:47 AM

According to the FHS:
Quote:

/mnt : Mount point for a temporarily mounted filesystem
Purpose

This directory is provided so that the system administrator may temporarily mount a filesystem as needed. The content of this directory is a local issue and should not affect the manner in which any program is run.

This directory must not be used by installation programs: a suitable temporary directory not in use by the system must be used instead.
So mounting directly to /mnt would work, but it is not standard practice to mount a filesystem directly to /mnt. The standard way is to use a mount point under /mnt.

imayneed 07-14-2012 01:56 AM

Yes, I understand that.
On this case; I had to fit the codes into the Grub 256 byte limit. Therefore, mounting to an existing place seemed easier.
Originally, what was advised was to create and put it in /tmp/local_dev.
I am just learning the stuff, so it is like I am experimenting.
Now, I am wondering that if I would get the same result if I created /tmp/a and mounted it there.
I will try probably.
Thanks.


All times are GMT -5. The time now is 06:36 AM.