0% found this document useful (0 votes)
61 views

Linux Mount Devices Tutorial

The document provides instructions for automatically mounting hard disk partitions in Ubuntu at system startup. It includes the following steps: 1) Use sudo fdisk -l to list disk partitions and identify the ones to mount; 2) Create mount folders for each partition with sudo mkdir; 3) Edit /etc/fstab to add entries specifying which partitions to mount where, using the format /dev/sda# /media/folder defaults; 4) Mount partitions with mount -a and reboot.

Uploaded by

nic b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Linux Mount Devices Tutorial

The document provides instructions for automatically mounting hard disk partitions in Ubuntu at system startup. It includes the following steps: 1) Use sudo fdisk -l to list disk partitions and identify the ones to mount; 2) Create mount folders for each partition with sudo mkdir; 3) Edit /etc/fstab to add entries specifying which partitions to mount where, using the format /dev/sda# /media/folder defaults; 4) Mount partitions with mount -a and reboot.

Uploaded by

nic b
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

sudo mount /dev/sda1 /mnt &&

sudo mount --bind /dev /mnt/dev &&


sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt

sudo umount /mnt/sys &&


sudo umount /mnt/proc &&
sudo umount /mnt/dev/pts

nic@ubuntu:~$ sudo fdisk -l


sudo mkdir /media/disk1
nano /etc/fstab

/dev/sda1 /media/disk1 ntfs defaults 0 0

mount -o remount,rw /
dpkg --configure -a
mount -o remount,ro /
sync
reboot

Ubuntu 14.04: How to Mount Hard Disk Partitions/Drives Automatically at System Startup
By Sourabh » Last Updated On: July 12, 2014 » How To, Ubuntu »

Let us learn how to automatically mount hard disk partitions/dives at system startup. By default, if
you have dual-boot PC (Linux Ubuntu and Windows installed on same PC), your hard drive
partitions are not automatically mounted when you start your system.

This also creates a problem in Ubuntu, if you are using dual-boot PC. Like windows, Ubuntu
doesn’t assign disk drive letters (c:/, d:/ and so on) to each drives and Ubuntu assigns “Disk”,
“Disk1”, “Disk2”. This name is assigned by the order of the first-mounted-device. Which means, if
names are assigned in order at which they are mounted, the drive which gets mounted first – Disk
and second – Disk1 and so on.

This is a problem. For example, if hard drive partition (say 100GB – Files and Folders) is mounted
first it is assigned “Disk” during one session and “Disk1” in another session (in another session
100GB partition is mounted second). This change causes problem, you cannot access your files and
folders normally.

The only way to fix this issue is to mount drive partitions at system startup. Here is how to do this:
Step 1: List Drive Partitions

Type the following command in the Terminal to list all drive partitions on your system:
sudo fdisk -l
you may be asked the password of the system to continue.

Disk-Mounting-01

Now you can see your system’s hard disk partitions. Linux uses /dev/sda1, /dev/sda2, /dev/sda3 and
so on to name each disk partitions. Locate the disk partition which you want to mount automatically
on system startup.

In my case, i have automatically mounted /dev/sda2 and /dev/sda3 diske partitions and assigned
the name disk1 and disk2 respectively.

Step 2: Create Mounting Folders

Now you have to create mounting folders for each of the disk partitions separately.

Type the following command in Terminal to create mount folders:


sudo mkdir /media/disk1
sudo mkdir /media/disk2

I have created two different mounting folders – /media/disk1 and /media/disk2 for disk partition
/dev/sda2 and /dev/sda3. The name of the disk will vary as per your disk partitions. Please select the
appropriate disk name.

Disk-Mounting
Step 3: Edit Mount Folders

This is the most important step and should be done cautiously. This step tells Ubuntu what hard
drives partitions have to be mounted automatically at system startup.

To edit mount table, type the following command:


gksudo gedit /etc/fstab

Fstab is a configuration file that contains all the necessary details for each drive partitions and files
which need to be mounted. In other words we can say that /etc/fstab configuration file contains the
automate-mounting information.

Type the following line-command at the end of the /etc/fstab configuration file and save the file:
/dev/sda2 /media/disk1 ntfs defaults 0 0
/dev/sda2 /media/disk2 ntfs defaults 0 0

================================================================

sudo mount -o remount,rw /


sudo dpkg --configure -a
sudo mount -o remount,ro /
sudo sync
sudo reboot

from Ubuntu 13.04 to 13.10: Filesystem check or mount failed

It seems it worked for others, but not for me after inserting the second line, it was aborted by
following error:

processing was halted because there were too many errors.

Also I tried other commands too, but after i inserted the "reboot" command it wouldn't work and
also I can't write any other commands anymore on it.
Please do not cargo-cult stuff you found on the Internet, but try to understand what a command does
before your enter it.

Your use of sudo is unnecessary -- you are already logged in as the root user, and have full access.

The error message you were given indicates that the automatic file system check failed. With ext2,
that happened often after a power outage, but with ext3 and ext4, one of which you are likely to be
using if your system is newer than ten years, this generally does not happen unless there is faulty
hardware involved.

The first command, mount -o rw,remount / essentially tells the system "It is fine, there are no errors
on this disk, and you can assume the file system to be consistent enough to write files." This is a
bold statement, especially right after you received an error message stating that a file system check
found problems that are so bad that the automated repairs would probably have to delete files in
order to get the file system back into working shape.

The second command, dpkg --configure -a then attempted to run the post-installation scripts for
packages that are marked in the dpkg database as having their files unpacked, but the scripts not run
yet. If this command attempted to do anything, this means that you will need to do that later on, but
now is not the proper time. The dpkg tool exists all file systems to be mounted and error-free, you
only have a root file system with errors, and all others are missing.

The way to resolve your situation is:

Go back to read-only mode using mount -o ro,remount /. You do not want the kernel to change
anything in the file system while the repair is under way.

Repair the root file system, using the fsck utility, which will then use the fsck.ext3 utility
internally: fsck -f /.

You can add the option -C0 to get a progress indicator.

If you get messages about fsck being unable to read blocks because of I/O errors, you can
interrupt with Ctrl-C and add the -c option to scan for bad blocks beforehand. This will take ages,
but the repair operation then does not attempt to rescue any files spread over defective sectors.

Most likely you will be asked if you agree to certain problems being fixed. Look up the error
messages using your search engine of choice, there is ample documentation on the Internet. Most of
these are about deleting files that are beyond repair, or moving them to the lost+found directory.

After that is complete, you will most likely be asked to reboot, in capital letters. This is a good
idea, just enter sync first, give the disks a few seconds to write out the remaining data and then
press Ctrl-Alt-Del. The reboot will be immediate, without unmounting file systems, but that is fine
because the only file system mounted is read-only.

If after the reboot you are dropped back into the same prompt, another file system but the root
file system is in need of repairs as well. Use the fsck -A command to attempt an automated repair of
all non-root file systems, and manually repair those that need it. This time around, you should not
be asked to reboot, as this is only needed for file systems that are mounted while being checked.

For those who are still in trouble:

fsck -f (/dev/sda1)

did not resolve my problem bescause all fs where no mounted. After fsck I did :

mountall

And then I had a prompt login ! I used my loal user to log in, and then :

startx

to have a graphical environement, and then :

unity --replace

to have unity.
================================================================

ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters
--block-size=SIZE scale sizes by SIZE before printing them. E.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes. See SIZE format below.
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information)
with -l: show ctime and sort by name
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output. WHEN defaults to 'always'
or can be 'never' or 'auto'. More info below
-d, --directory list directory entries instead of contents,
and do not dereference symbolic links
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g like -l, but do not list owner
--group-directories-first
group directories before files.
augment with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group in a long listing, don't print group names
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
--si likewise, but use powers of 1000 not 1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k, --kibibytes use 1024-byte blocks
-l use a long listing format
-L, --dereference when showing file information for a symbolic
link, show information for the file the link
references rather than for the link itself
-m fill width with a comma separated list of entries
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
-N, --literal print raw entry names (don't treat e.g. control
characters specially)
-o like -l, but do not list group information
-p, --indicator-style=slash
append / indicator to directories
-q, --hide-control-chars print ? instead of non graphic characters
--show-control-chars show non graphic characters as-is (default
unless program is 'ls' and output is a terminal)
-Q, --quote-name enclose entry names in double quotes
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse reverse order while sorting
-R, --recursive list subdirectories recursively
-s, --size print the allocated size of each file, in blocks
-S sort by file size
--sort=WORD sort by WORD instead of name: none -U,
extension -X, size -S, time -t, version -v
--time=WORD with -l, show time as WORD instead of modification
time: atime -u, access -u, use -u, ctime -c,
or status -c; use specified time as sort key
if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, +FORMAT.
FORMAT is interpreted like 'date'; if FORMAT is
FORMAT1<newline>FORMAT2, FORMAT1 applies to
non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time
with -l: show access time and sort by name
otherwise: sort by access time
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS assume screen width instead of current value
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-Z, --context print any SELinux security context of each file
-1 list one file per line
--help display this help and exit
--version output version information and exit

SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units


are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).

Using color to distinguish file types is disabled both by default and


with --color=never. With --color=auto, ls emits color codes only when
standard output is connected to a terminal. The LS_COLORS environment
variable can change the settings. Use the dircolors command to set it.

Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).

You might also like