blob: 337c6d8bed888559fee9653b359f5a50b86c5d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/bash
# Specify the Ubuntu distro and the USB stick path
UBUNTU_DISTRO="lunar" # For example: focal, bionic, etc.
USB_PATH="/mnt/external" # Path where USB is mounted
# The location of the repository to mirror
REPO="http://archive.ubuntu.com/ubuntu"
# Use debmirror to download the repository
debmirror --host=archive.ubuntu.com \
--root=ubuntu \
--method=https \
--progress \
--dist="${UBUNTU_DISTRO},${UBUNTU_DISTRO}-updates,${UBUNTU_DISTRO}-backports,${UBUNTU_DISTRO}-security" \
--section=main,restricted,universe,multiverse \
--arch=amd64 \
--nosource \
"${USB_PATH}/ubuntu/"
chmod -R 744 "${USB_PATH}"
# Create the USAGE.md file with the sources.list instructions
echo "To use this local mirror of the Ubuntu repository:
1. Mount the USB stick on your Ubuntu system. You can use the mount command:
'sudo mount /dev/sdx /mnt' (replace /dev/sdx with your USB device).
2. Backup your current sources.list file:
'sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak'
3. Modify the /etc/apt/sources.list file:
'sudo nano /etc/apt/sources.list'
Comment out the existing lines (put a '#' at the start of the line) to keep them for later.
Add the following line to the file:
deb file:/mnt/ubuntu/ ${UBUNTU_DISTRO} main restricted universe multiverse
deb file:/mnt/ubuntu/ ${UBUNTU_DISTRO}-updates main restricted universe multiverse
deb file:/mnt/ubuntu/ ${UBUNTU_DISTRO}-backports main restricted universe multiverse
4. Update APT:
'sudo apt-get update'
Now APT will use the local mirror on the USB stick when installing packages." > "${USB_PATH}/USAGE.md"
echo "Mirroring completed and instructions written to USAGE.md"
|