Add Hard Drive to Ubuntu Server

Install the internal hard drive or plug in the USB external hard drive. Use lsusb to show your external hard drive. Use fdisk to identify the new hard drives:

$ sudo fdisk -l | sd*

Start fdisk:

$ sudo fdisk /dev/sde

List partitions and delete existing partition and create new partition:

p (to list partitions)
d (to delete existing partition)
1 (which partition to delete)
n (new partition)
1 (new partition number)
default (start of partition)
default (end of partition)
y (to remove signature)
w (to write changes)

Next, make the file system:

$ sudo mkfs -t ext4 /dev/sde1

Hard Drive Larger than 2TBpar

parted /dev/sde
mklabel gpt
mkpart primary 0TB 12TB

$sudo mkfs.ext4 /dev/sde1

Copy Files from Old Hard Drive with Rsync

rsync -a /media/storage/ /media/hdd3


Creating an Ubuntu Repository

Setting up a local Ubuntu repository can be used to save internet bandwidth and to do updates with minimal or no internet connection. My starting point is a tutorial by LinuxConfig.

$ sudo apt install apache2
$ sudo systemctl enable apache2

$ sudo mkdir -p /var/html/mirror
$ sudo chown www-data:www-data /var/html/mirror

$ sudo apt install apt-mirror

Edit /etc/apt/mirror.list. Change base_path to the mirror directory. Change the ubuntu release name to match the release you are using. Comment out the source archives to reduce the size of the repository.

$ sudo cp /var/spool/apt-mirror/var/postrmirror.sh /var/mirror/var

$ sudo apt-mirror

$ sudo crontab -e

add the following line to update nightly at 2:30 PM:

30 02 * * * /usr/bin/apt-mirror

Configure Clients to use Local Repository

Edit /etc/apt/sources.list and comment any line referring to repositories not mirrored in your server