Ubuntu: I am new to ubuntu and have some questions way beyond a first timer



Question:

Back story is I was given a desktop with ubuntu 12.04 installed and the guy could not remember any of his setup(u/n pass) info. He told me to just install what os i wanted over his. When i did this i didn't realize there were 2 HDDs in it. When I did the install it wrote over the HDD that didn't have his os. I would like to delete his old os since it is locked and unusable. My second problem is that if I dont go to boot priority(f12) and select HDD even though it is first in priority. then it goes to GRUB and i pick Lubuntu. If someone could help i would really appreciate it as i have already found lots of help here lurking. Thank you in advance.


Solution:1

Linux has a multitude of ways to do each of these steps; this is just one way. Of course, it goes almost without saying that most of this is dangerous if done heedlessly. Use at your own risk as they say.

Step #1: Format Disk

This prepares the disk to be partitioned. This is only needed if you want to format an entire drive. Otherwise, skip to step 2 and just write a new partition over the old one.

Step #1a: Find the Recognized Disks and their Partitions

To list all drives use:

sudo fdisk -l /dev/sdb  

Which only works when the drive is NOT mounted. To list the drives at any time use the longer:

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL  

A device name refers to the entire hard disk. Nowadays, nearly everything uses SCSI or Linux has an emulated serial interface driver for it. Meaning that they'll all be named sda, sdb, sdc, etc.. Each drive is given a letter designation in the order that they appear in the BIOS; this means that if you rearrange the drives in your BIOS they get moved and your mount points will likely all break.

The only common exception are RAM drives which use sr0, sr1, sr2, etc... These are enumerated more like partitions than drives. Being that they all exist on the same device they really are more like partitions. Drive tools like the ones you are using may list them as drives though; they are a special case though and you don't need to worry about it now.

If you are using an older Linux distribution (or just one which is very specific to a certain piece of hardware) you may also see hda, hdb, hdc, etc... These are the old non serial IDE drivers and for these purposes will work exactly the same a SCSI drivers.

Step #1B: Format the Disk:

This step will also erase ALL PARTITIONS on the disk so make sure that this is what you want to do before you do step 1b.

Now that you've found the disk you want to format, it is time to do it. Use this to format the disk:

sudo fdisk /dev/sdb  

The basic fdisk commands you need are:

  • m - print help
  • p - print the partition table
  • n - create a new partition
  • d - delete a partition
  • q - quit without saving changes
  • w - write the new partition table and exit

Step#2 : Partition the disk using mkfs.ext3 command

As long as your disk is formatted, all you'll need to do is work with your partitions. Partitions are logical divisions on your disk. In case you're wondering, this will destroy everything on the partition.

To format Linux partitions using ext2fs on the new disk:

sudo mkfs.ext3 /dev/sdb1  

Notice that when we work with specific partitions they have names ending with a number (eg /dev/sda1 instead of just /dev/sda). Each partition is given a sequential number based on which sector it begins at.

Step#3 : Mount the new disk using mount command

Mounting a disk allows the OS to use the disk (beyond simple partition and format operations). A mount point is a point on the system directory tree which you'd like to put the drive. This can be any folder but by convention it is usually a folder in the /mnt in Ubuntu (some distros will use /mount instead). Ubuntu has a directory called /media which confusses people a lot. /media is where the system will automount drives such as DVD or USB drives. Most people avoid mounting their own drives in this folder

First create a mount point /mnt/disk1 and use mount command to mount /dev/sdb1, enter:

sudo mkdir /mnt/disk1  sudo mount /dev/sdb1 /mnt/disk1  df -H  

Step#4 : Update the File System Table:

If we want the disk to automatically be mounted when we boot we need to tell the OS as much. This is done in the fstab file. To open the /etc/fstab file, enter:

sudo vi /etc/fstab  

Use whatever text editor you want for this (vi is just an example). Append to this file the mount information a line similar to the following:

/dev/sdb1               /mnt/disk1           ext3    defaults        1 2  

Where /dev/sdb1 is the partition to mount, /mnt/disk1 is the folder to mount to, ext3 is the file system type, defaults are the mount options (see man mount), 1 is weather to back the drive up using the system dump command and 2 is the order this drive should be scanned when the system does a file system error scan. Save and close the file.

As a note, the fstab file has a sister file called mtab. The mtab file contains a listing of all of the currently mounted file systems. You can look at it to see how everything currently mounted was mounted. Do not edit mtab directly though as it is used by the umount command to unmount these file systems later and editing this may break your ability to unmount a drive properly.


Optional Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backup, enter:

sudo e2label /dev/sdb1 /backup  

You can use label name instead of partition name to mount disk using /etc/fstab:

LABEL=/backup /disk1 ext3 defaults 1 2  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »